From bce1f154448837666fa82d634138e22c723cd51c Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Tue, 15 Sep 2015 14:53:01 -0700 Subject: [PATCH] Update knn.go to allow all FloatAttributes. --- knn/knn.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/knn/knn.go b/knn/knn.go index 38c9e7e..c003a54 100644 --- a/knn/knn.go +++ b/knn/knn.go @@ -124,6 +124,12 @@ func (KNN *KNNClassifier) Predict(what base.FixedDataGrid) base.FixedDataGrid { } } + // If every Attribute is a FloatAttribute, then we remove the last one + // because that is the Attribute we are trying to predict. + if len(allNumericAttrs) == len(allAttrs) { + allNumericAttrs = allNumericAttrs[:len(allNumericAttrs)-1] + } + // Generate return vector ret := base.GeneratePredictionVector(what)