[PYTHON] Introduction to machine learning ~ Let's show the table of K-nearest neighbor method ~ (+ error handling)

Introduction

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.

Error message

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)

Solution

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)

Display the graph of k-nearest neighbor method in Jupyter Notebook

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

Introduction to machine learning ~ Let's show the table of K-nearest neighbor method ~ (+ error handling)
Introduction to machine learning
Machine learning #k-nearest neighbor method and its implementation and various
An introduction to machine learning
Super introduction to machine learning
Machine learning ④ K-nearest neighbor Summary
A simple Python implementation of the k-nearest neighbor method (k-NN)
Try to evaluate the performance of machine learning / classification model
How to increase the number of machine learning dataset images
[Machine learning] I tried to summarize the theory of Adaboost
[Machine learning] Write the k-nearest neighbor method (k-nearest neighbor method) in python by yourself and recognize handwritten numbers.
Introduction to machine learning Note writing
I tried to make Othello AI with tensorflow without understanding the theory of machine learning ~ Introduction ~
Introduction to Python Basics of Machine Learning (Unsupervised Learning / Principal Component Analysis)
Before the introduction to machine learning. ~ Technology required for machine learning other than machine learning ~
How to use machine learning for work? 01_ Understand the purpose of machine learning
Introduction to Machine Learning Library SHOGUN
[Introduction to StyleGAN] Unique learning of anime with your own machine ♬
[Golang Error handling] The best way to separate processing according to the type of error
Take the free "Introduction to Python for Machine Learning" online until 4/27 application
Basic machine learning procedure: ③ Compare and examine the selection method of features
[Introduction to Python] What is the method of repeating with the continue statement?
Introduction to Machine Learning: How Models Work
Record the steps to understand machine learning
Introduction to ClearML-Easy to manage machine learning experiments-
An introduction to Python for machine learning
Evaluation method of machine learning regression problem (mean square error and coefficient of determination)
[Super Introduction] Machine learning using Python-From environment construction to implementation of simple perceptron-
Free version of DataRobot! ?? Introduction to "PyCaret", a library that automates machine learning
I tried to predict the presence or absence of snow by machine learning.
Introduction to Machine Translation Architecture by the University of Cambridge by Slack Translation App Kiara
[Introduction to cx_Oracle] (16th) Handling of LOB types
[Python] Easy introduction to machine learning with python (SVM)
[Super Introduction to Machine Learning] Learn Pytorch tutorials
An introduction to machine learning for bot developers
[Introduction to cx_Oracle] (Part 3) Basics of Table Reference
[Super Introduction to Machine Learning] Learn Pytorch tutorials
About the development contents of machine learning (Example)
[Translation] scikit-learn 0.18 Tutorial Introduction of machine learning by scikit-learn
[Introduction to cx_Oracle] (5th) Handling of Japanese data
[Introduction to cx_Oracle] (Part 7) Handling of bind variables
From the introduction of pyethapp to the execution of contract
[For beginners] Introduction to vectorization in machine learning
Arrangement of self-mentioned things related to machine learning
The first step of machine learning ~ For those who want to implement with python ~
[Machine learning] "Abnormality detection and change detection" Let's draw the figure of Chapter 1 in Python.
[Introduction to Sound] Let's arrange the introduction to sounds of python and R ♬-Listen to the sound of the explosion of Nikkei 255-
A quick introduction to the neural machine translation library
Impressions of taking the Udacity Machine Learning Engineer Nano-degree
About testing in the implementation of machine learning models
Predict the gender of Twitter users with machine learning
Summary of the basic flow of machine learning with Python
Record of the first machine learning challenge with Keras
[Introduction to Python] Basic usage of the library matplotlib
An introduction to machine learning from a simple perceptron
I tried to compress the image using machine learning
A concrete method of predicting horse racing by machine learning and simulating the recovery rate
I tried to compare the accuracy of machine learning models using kaggle as a theme.
I tried to verify the yin and yang classification of Hololive members by machine learning
I considered the machine learning method and its implementation language from the tag information of Qiita