示例#1
0
func TestMeanSquared(t *testing.T) {
	X, y := datasets.Load("cancer")
	tree, _ := DecisionTree(4, GINI)
	tree.Fit(X, y)
	yPred := tree.Classify(X)
	err := metrics.MeanSquaredError(yPred, y)
	fmt.Printf("cancer mean sq: %.3f\n", err)
}
示例#2
0
func TestCancer(t *testing.T) {
	X, y := datasets.Load("cancer")
	datasets.RandomShuffle(X, y)
	XTrain, XTest := X[:67], X[67:]
	yTrain, yTest := y[:67], y[67:]

	beta := LinearRegression(XTrain, yTrain)

	// validate on held out data
	yPred := matrix.VecMult(XTest, beta)
	fmt.Println("cancer error", metrics.MeanSquaredError(yPred, yTest))
}