Question 16
You are working with a dataset containing 1000 samples, aiming to classify them using the KNeighborsClassifier from scikit-learn. After trying an initial configuration, you observe that the model seems to be overfitting, with the following accuracies:
from sklearn.neighbors import KNeighborsClassifierfrom sklearn.metrics import accuracy_score
# Initial Configurationknn = KNeighborsClassifier(n_neighbors=4)knn.fit(X_train, y_train)train_acc = accuracy_score(y_train, knn.predict(X_train))val_acc = accuracy_score(y_val, knn.predict(X_val))- Training accuracy: 98%
- Validation accuracy: 65%
After observing such performance of the model, Which of the following values for n_neighbors would be most suitable to try next?
1
2
10
500