Exemplo n.º 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)
}
Exemplo n.º 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))
}
Exemplo n.º 3
0
func TestPrint(t *testing.T) {
	X, y := datasets.Load("cancer")
	tree, _ := DecisionTree(4, GINI)
	tree.Fit(X, y)
	fmt.Println(tree)
}
Exemplo n.º 4
0
func TestBreastCancer(t *testing.T) {
	X, y := datasets.Load("cancer")
	perf := testDataset(X, y)
	fmt.Printf("Breast Cancer: %.3f\n", perf)
}
Exemplo n.º 5
0
func TestWithIris(t *testing.T) {
	X, y := datasets.Load("iris")
	perf := testDataset(X, y)
	fmt.Printf("Iris: %.3f\n", perf)
}