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?
def k_neighbor(input_data, k, p): """Returns the k-neighbor estimate for p using data input_data.
Keyword arguments:
input_data -- NumPy array of all the data
k -- Number of k
p -- input values
Here is the function call
data = np.array([1,3,4,5,7,8,11,12,13,15,19,24,25,29,40]) print(k_neighbor(input_data=data, k=3, p=5))