How to perform KNN regression

조회 수: 6 (최근 30일)
Mekala balaji
Mekala balaji 2017년 8월 26일
댓글: Image Analyst 2017년 8월 26일
Hi,
I have data as below:
X:
1
2
3
4
9
11
13
17
19
20
y:
0.1
0.3
0.4
0.65
1.5
2.5
2.7
2.9
3.2
3.6
I want to compute y values for at x values at 6.3, 15.5&21.5
1. for each value of x, I want to take 4 nearest points in my calculation and choose most reasonable one as the final y
2. In the second method, compare minkowski & chebychev distances and choose most reasonable one
Many thanks in advance,
  댓글 수: 2
Jan
Jan 2017년 8월 26일
There is no "most reasonable" in maths. You want a valus for x=21.5, but the original data stop at x=20. There is an infinite number of possible ways to extrapolate. Without any further information like "the data follow a polynomial of order 3" it is not possible to prefer any method or even to measure the degree or reasonability. Perhaps a linear interpolation is fair, and the extrapolated values should be simply NaN.
Image Analyst
Image Analyst 2017년 8월 26일
"In the second method, compare ....." sounds like a homework problem,

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

답변 (1개)

Royi Avital
Royi Avital 2017년 8월 26일
At each point you want to calculate the value (x, y) find the K closest point (For x).
Then average them to create the new value.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by