Question: Help to implement K nearest neighbor in python. Can only import numpy and nothing else. The training data and test data is a 2D numpy
Help to implement K nearest neighbor in python. Can only import numpy and nothing else. The training data and test data is a 2D numpy array and the Labels are a 1D numpy array EX. labels = [[1],[-1],[1]] features = [[1,2],[5,8],[3,10]]

2 Nearest Neighbors (20 points) Implement a function in python: KNN test (X_train,Y train,X test,Y test,K) that takes training data, test data, and K as inputs. KNN test (X.train, Ytrain,X test,Y test,K) should return the accuracy on the test data. The training data and test data should have the same format as described earlier for the decision tree problems. Your function should be able to handle any dimension feature vector, with real-valued features. Remember your labels are binary, and they should be 1 for the negative class and 1 for the positive class. Write-Up: describe your implementation in detail. 2 Nearest Neighbors (20 points) Implement a function in python: KNN test (X_train,Y train,X test,Y test,K) that takes training data, test data, and K as inputs. KNN test (X.train, Ytrain,X test,Y test,K) should return the accuracy on the test data. The training data and test data should have the same format as described earlier for the decision tree problems. Your function should be able to handle any dimension feature vector, with real-valued features. Remember your labels are binary, and they should be 1 for the negative class and 1 for the positive class. Write-Up: describe your implementation in detail
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
