k nearest neighbor regression function

Hi,
What is the k nearest neighbour regression function in matalb? Is only knn classification function available?
Regards
Farideh

1 件のコメント

denny
denny 2018 年 4 月 4 日
i want to find it too.

サインインしてコメントする。

回答 (5 件)

wang guangyi
wang guangyi 2015 年 11 月 17 日

0 投票

i can not find it too
Satadru Mukherjee
Satadru Mukherjee 2020 年 3 月 10 日
編集済み: Satadru Mukherjee 2020 年 3 月 10 日

0 投票

clc
clear all
close all
x=input('Enter the x coordinates:');
y=input('Enter the y coordinates:');
z=[];
a=input('Enter the x coordinate of which , you want to predict the y value:');
k=input('Enter the k value:');
for i=1:length(x)
z=[z abs(x(i)-a)];%difference calculation
end
temp=0;
gemp=0;
for i=1:length(z)
for j=1:(length(z)-i)
if(z(j)>z(j+1))
temp=z(j);
z(j)=z(j+1);
z(j+1)=temp;
gemp=y(j);
y(j)=y(j+1);
y(j+1)=gemp;
end
end
end
tuka=0;
for i=1:k
tuka=tuka+y(i);
end
output=tuka/k
Image Analyst
Image Analyst 2020 年 3 月 10 日

0 投票

Perhaps fitcknn()

1 件のコメント

Satadru Mukherjee
Satadru Mukherjee 2021 年 1 月 18 日
fitcknn is for classification , not for regression

サインインしてコメントする。

Bechir EL HOSNI
Bechir EL HOSNI 2020 年 9 月 3 日
編集済み: Bechir EL HOSNI 2020 年 9 月 3 日

0 投票

Hi
KNN is a non parametric method used in machine learning.
We find two knid of KNN:
KNN classifier: Used in classification problem in which the ouput is a categorical variable.
KNN regression : Used in regression problem in which the output is a numerical variable.
In the context of regression problem we indentifie the first the K (Integer) nearest training points, to the observation we want to predict its output, and next we compute the average of the value of those points. The optimal value of K depend on the "Bias-Vriance tradeoff" ( a very important concept in statistic and machine learning).
Thanks.
Elaheh Shamsi
Elaheh Shamsi 2020 年 9 月 23 日

0 投票

Hi
you can use this link to use KNN regression
this paper uses one type of KNN regression to make the QSAR model.
good luck

質問済み:

2013 年 11 月 6 日

コメント済み:

2021 年 1 月 18 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by