diff --git a/knn/knn_test.go b/knn/knn_test.go index 6c3fd12f..ddf1834e 100644 --- a/knn/knn_test.go +++ b/knn/knn_test.go @@ -65,3 +65,17 @@ func TestKnnClassifierWithOptimisations(t *testing.T) { }) }) } + +func TestKnnClassifierWithOptimisationsPartiallyComplete(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.ParseCSVToInstances("knn_test_2.csv", true) + So(err, ShouldBeNil) + + cls := NewKnnClassifier("euclidean", 2) + cls.Fit(trainingData) + predictions := cls.Predict(testingData) + So(predictions, ShouldNotBeNil) + }) +} diff --git a/knn/knn_test_2.csv b/knn/knn_test_2.csv new file mode 100644 index 00000000..797ad035 --- /dev/null +++ b/knn/knn_test_2.csv @@ -0,0 +1,3 @@ +weather,hours_of_daylight,number_of_customers +cloudy,10.1,0 +sunny,10.1,0 diff --git a/knn/knn_train_2.csv b/knn/knn_train_2.csv new file mode 100644 index 00000000..3dfb125f --- /dev/null +++ b/knn/knn_train_2.csv @@ -0,0 +1,5 @@ +weather,hours_of_daylight,number_of_customers +sunny,10.5,200 +sunny,10.1,188 +cloudy,10.0,150 +cloudy,8.5,100