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