필터 지우기
필터 지우기

k-NN search. What is the difference between these 2-codes ?

조회 수: 1 (최근 30일)
Pramod Bhat
Pramod Bhat 2012년 2월 15일
{
The program for k-NN search in MATLAB.
load fisheriris %inbuilt data set provided in MATLAB.
x = meas(:,3:4);
gscatter(x(:,1),x(:,2),species)
set(legend,'location','best')
newpoint = [5 1.45];
line(newpoint(1),newpoint(2),'marker','x','color','k',...
'markersize',10,'linewidth',2)
[n,d] = knnsearch(x,newpoint,'k',10) %my doubt is here.
line(x(n,1),x(n,2),'color',[.5 .5 .5],'marker','o',...
'linestyle','none','markersize',10)
%modified program for my requirement with different data set. x and z are the two variables with 24 elements in each.
load stroke
gscatter(x,z,species);
set(legend,'location','best')
newpoint=[115,150];
line(newpoint(1),newpoint(2),'marker','x','co lor','k',...
'markersize',10,'linewidth',2);
[n,d] = knnsearch(x,newpoint,'k',10) % when i run , it gives error here. what is the difference between the original code and modified code ? infact 'newpoint' in the original program is a vector.
line(x(n,1),x(n,2),'color',[.5 .5 .5],'marker','o',...
'linestyle','none','markersize',10)

채택된 답변

Tom Lane
Tom Lane 2012년 2월 15일
You have supplied only x, not [x z], as the first argument to knnsearch. Your newpoint vector, on the other hand, has two columns.
  댓글 수: 2
Pramod Bhat
Pramod Bhat 2012년 2월 16일
Hai. I have sent you an email. Please help me out in this regard.
Shaik Ghouse Basha
Shaik Ghouse Basha 2013년 9월 8일
How to predict data using KNN ?
I have a vector of 80 years of data. I want to predict for 30 years. Please let me know how it is possible to using KNN?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile 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!

Translated by