k nearest neighbor regression function
43 views (last 30 days)
Satadru Mukherjee on 10 Mar 2020
Edited: Satadru Mukherjee on 10 Mar 2020
x=input('Enter the x coordinates:');
y=input('Enter the y coordinates:');
a=input('Enter the x coordinate of which , you want to predict the y value:');
k=input('Enter the k value:');
z=[z abs(x(i)-a)];%difference calculation
Bechir EL HOSNI on 3 Sep 2020
Edited: Bechir EL HOSNI on 3 Sep 2020
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).
Elaheh Shamsi on 23 Sep 2020