machine learning - Matlab KNNClassify Consensus -
i use knnclassify consensus. try find missing values in class label using consensus.
this code;
rb = randperm(120); rm = randperm(120); labeled = labeled(rb,:); unlabeled = unlabeled(rm,:); cnt = 0; sonuc = zeros(120,1); i=1:120 pred=knnclassify(unlabeled,labeled,labeledclass,10,'correlation','consensus'); if pred>=1 cnt=cnt+1; sonuc(i)= pred; end end cnt;
and workspace;
my workspace benign , malignant class values http://imgbox.com/emwvlqnv
code not return error pred return nan in row , return 1 warning;
warning: points in data have small relative standard deviations, making them constant. correlation metric may not appropriate these points. > in pdist2 @ 304 in exhaustivesearcher.knnsearch @ 207 in knnsearch @ 142 in knnclassify @ 162 in cancerknnconsensus @ 11
i try euclidean, cosine, cityblock , correlation. how fix this?
the error message telling of data have small std , constant, cause problems when using correlation distance.
the correlation distance in matlab subtract mean of data first. constant data vector, subtracting mean result in 0 vector, , correlation of constant vector other data vector not defined.
my suggestion fix problem follows:
- identify these data points based on std, , remove these data small std before using knn clusfier;
- normalize data may help;
- try other distance metric.
hope helpful.
Comments
Post a Comment