Skip to content

Commit

Permalink
knn: adding additional test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Sentimentron committed Jul 11, 2016
1 parent 7041fc3 commit f339111
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion knn/knn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestKnnClassifierWithOptimisations(t *testing.T) {
})
}

func TestKnnClassifierWithOptimisationsPartiallyComplete(t *testing.T) {
func TestKnnClassifierWithTemplatedInstances1(t *testing.T) {
Convey("Given two basically identical files...", t, func() {
trainingData, err := base.ParseCSVToInstances("knn_train_2.csv", true)
So(err, ShouldBeNil)
Expand All @@ -79,3 +79,17 @@ func TestKnnClassifierWithOptimisationsPartiallyComplete(t *testing.T) {
So(predictions, ShouldNotBeNil)
})
}

func TestKnnClassifierWithTemplatedInstances1Subset(t *testing.T) {
Convey("Given two basically identical files...", t, func() {
trainingData, err := base.ParseCSVToInstances("knn_train_2.csv", true)
So(err, ShouldBeNil)
testingData, err := base.ParseCSVToTemplatedInstances("knn_test_2_subset.csv", true, trainingData)
So(err, ShouldBeNil)

cls := NewKnnClassifier("euclidean", 2)
cls.Fit(trainingData)
predictions := cls.Predict(testingData)
So(predictions, ShouldNotBeNil)
})
}
2 changes: 2 additions & 0 deletions knn/knn_test_2_subset.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
weather,hours_of_daylight,number_of_customers
cloudy,10.1,0

0 comments on commit f339111

Please sign in to comment.