Skip to content

Commit

Permalink
knn: replicating issue sjwhitworth#143 in test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Sentimentron committed Jul 11, 2016
1 parent 063aab5 commit 457a00a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions knn/knn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
3 changes: 3 additions & 0 deletions knn/knn_test_2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
weather,hours_of_daylight,number_of_customers
cloudy,10.1,0
sunny,10.1,0
5 changes: 5 additions & 0 deletions knn/knn_train_2.csv
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 457a00a

Please sign in to comment.