Applied Data Science With Python and Jupyter by Alex Galea

Applied Data Science With Python and Jupyter by Alex Galea

Author:Alex Galea
Language: eng
Format: epub
Published: 2018-12-05T00:00:00+00:00


Train the KNN classifier with n_neighbors=3, and then compute the accuracy and decision regions. Run the cell containing the following code:knn = KNeighborsClassifier(n_neighbors=3)

knn.fit(X_train_std, y_train)

check_model_fit(knn, X_test_std, y_test)

Figure 2.31: Training the kNN classifier with n_negihbours=3

Figure 2.32: Enhanced results after training

We see an increase in overall accuracy and a significant improvement for class 1 in particular. However, the decision region plot would indicate we are overfitting the data. This is evident by the hard, "choppy" decision boundary, and small pockets of blue everywhere. We can soften the decision boundary and decrease overfitting by increasing the number of nearest neighbors.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.