Plot data according th k_dist chart using KNNN
    5 ビュー (過去 30 日間)
  
       古いコメントを表示
    
I have used KNN to detect the kth items near a specific point according to the code bellow, But iam not sure how can i use KNN to produce k-dist chart for my dataset , it help to detect epsilon :
   clc;
   clear all;
  %%%%%%%%%%%%%%%%%%
  load fisheriris
  x=meas(:,3:4);
  k=5;
  newpoint=[ 5 1.45]
  %%%%%%%%%%%%%%%%%%
     function [neighborIds neighborDistances,x_closest]= kNearestNeighbors(dataMatrix, queryMatrix, k)
   neighborIds = zeros(size(queryMatrix,1),k);
   neighborDistances = neighborIds;
   numDataVectors = size(dataMatrix,1);
   numQueryVectors = size(queryMatrix,1);
    for i=1:numQueryVectors,
     dist = sum((repmat(queryMatrix(i,:),numDataVectors,1)-dataMatrix).^2,2);
    [sortval sortpos] = sort(dist,'ascend');
    neighborIds(i,:) = sortpos(1:k);
    x_closest=dataMatrix(neighborIds,:);
    neighborDistances(i,:) = sqrt(sortval(1:k));
end
0 件のコメント
回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Statistics and Machine Learning Toolbox についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
