Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

no, you cannot do this.

instead, use a lookup table of strings, and use the prediction / label value as index, maybe like this:

String lut [] = {"apples", "pears", "oranges"};
int predicted = knn.findNearest( testData, 3);
String fruit = lut[predicted];

(btw, you should use integer labels for KNearest, not float)