On 5/7/2013 10:39 AM, Jay wrote: > Hello! > > I believe there is either a bug in ClassificationKNN.predict or the > documentation to ClassificationKNN.fit is wrong (or both). > 1. > The documentation states, that Y is supposed to be a numeric vector, > however in the example how to construct a KNN classifier 'species' of > the dataset 'fisheriris' is used as Y which is a cell array of strings. > > 2. > I have initialized my KNN classifier how it is done in the example, > using a cell array of strings as Y. My "training" looks like this: > mdl = ClassificationKNN.fit(featMat(train,:),classLabels(train,:), > 'BreakTies', 'nearest', 'NumNeighbors', testParams.k, 'Distance', > @myDistance); > > If I now use classes = predict(mdl, featMat(test,:)); > I occasionally get errors. I believe this is the case when there are > actually ties. The error is: > Conversion to cell from double is not possible. > > Error in ClassificationKNN/predict (line 609) > label(notNanRows(i)) = > CNeighbor(notNanRows(i),inner); > > What can I do about it? Is that actually because I used a cell array > of strings as Y? Do I have to convert my class labels to numbers then? > > 3. > Also, while I am at it: If I want to see what examples were close to > an input observation and influenced the classification (so to speak > the nearest neighbors) I have no chance of doing that, do I? For that > I would have to switch entirely to knnsearch? > > Thank you!