Predict a numeric target for a query point as the average target of its k nearest training rows (squared Euclidean distance). Distance ties are resolved in favour of the earlier training row.
Implement solve(X,y,q,k).
Returns. Return the prediction as a Python float.
Example 1
Input:
solve([[0.0], [1.0], [2.0], [10.0]], [1.0, 2.0, 3.0, 100.0], [1.2], 2)
Output:
2.5
Example 2
Input:
solve([[0.0], [4.0]], [10.0, 20.0], [1.0], 2)
Output:
15.0
No results yet
Run your code to check it against the examples, or submit to run every test.