First time here? Checkout the FAQ!
x
+1 vote
352 views
asked in Machine Learning by (160 points)  

I have this question as an assignment, I am having challenges in interpreting this question.

Q4. Define a function that takes a 1-d numpy array, a parameter k, and a number p. The function returns an estimate equal to the mean of the closest k points to the number p

The challenge I have is, kNN seems to work for multi-dimensional arrays. howver, here this is a single D array.

Am i to write the function from scratch to loop through this single D array to find the closest numbers to the number P (from this singleD array?) In which case I need not use the kNN libraries, but use my own logic.

I am not exactly looking for the answer, but am looking for clarification.

Thank you

RSH

  

1 Answer

0 votes
answered by (140 points)  
You can use rshape function like: input_data.reshape(-1, 1)
commented by (160 points)  
Thank you Jun for the answer.
I managed to conver using reshape function into an array of (15,1).
however the question mentions a function that returns average of the closest k points to P in an array. with just a single digit, how do I determine the point ?

do I need to make an assumption for the y values ?

Thank you for your clarification

Raj
...