Classified NBA players into 5 positions (classes) on the basketball court using k-NN model. Performed 10-fold stratified cross-validation.
NBAstats.csv file
- Divided the data into a training set and a test set.
- Instantiated the KNeighborsClassifier class with weights as inverse of the distance and number of neighbors as 7.
- Used fit method to fit the classifier using the training set.
- Used predict method to make predictions on the test data.For each data point in the test set, this computes its nearest neighbors in the training set.
- Evaluated the model on the test set using the score method, which for classification computes the fraction of correctly classified samples.
- Used 10-fold stratified cross-validation. Observed the accuracy of each fold and the average accuracy across all folds.