I wanted to learn about the k-nearest neighbor method, and when I tried to display the graph, I got the following error message, so I will post the solution.
Perhaps some people will get the same error, so please refer to it.
You're saying you're importing something. However, I didn't understand at all, so I searched and forcibly solved it.
erorr.py
FutureWarning: Function make_blobs is deprecated; Please import make_blobs directly from scikit-learn
warnings.warn(msg, category=FutureWarning)
When I imported the code below, the error message disappeared.
success.py
from sklearn.model_selection import train_test_split
X, y = mglearn.datasets.make_forge()
X_train, X_test, y_train, y_test = train_test_split(X, y, ramdom_state=0)
nearest_neighbor_method_column1.py
import mglearn
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
X, y = mglearn.datasets.make_forge()
nearest_neighbor_method_column2.py
mglearn.plots.plot_knn_classification(n_neighbors=3)
The number of k is shown at n_neighbors = "".
It is natural to change this number freely, but the average value will change.
Thank you for watching until the end.
Recommended Posts