Question: Complete the class below which implements a KNN classifier ( and meets the requirements for being a sklearn predictor ) . You only need to
Complete the class below which implements a KNN classifier and meets the requirements for being a sklearn predictor You only
need to complete the fit and predict methods. You may modify the contents of any methods as you see fit but not the
signatures and you may make any other functions you want but prefix any additional functions with an underscore to avoid conflicts
with sklearn
Details:
will always be less than the number of training points.
All features will be numeric.
The number of features will be
Labels can be anything hashable so they can go in a dict or set
Use euclidean distance to compute distance between points.
In the event of a tie, you may choose which of the tied labels to predict.
predict must return a numpy.ndarray.
You may not use any sklearn functionality aside from the uses already provided sklearn. base. BaseEstimator and
sklearn.metrics.accuracyscoreclass MyKNNsklearnbase.BaseEstimator:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
