1
0
mirror of https://github.com/sjwhitworth/golearn.git synced 2025-04-28 13:48:56 +08:00

Merge pull request #118 from thedadams/master

Fix KNN if all Attributes are FloatAttribute
This commit is contained in:
Richard Townsend 2015-10-17 22:50:04 +01:00
commit 51ca101d6c

View File

@ -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)