René's URL Explorer Experiment


Title: The k-Nearest Neighbors (kNN) Algorithm in Python – Real Python

Open Graph Title: The k-Nearest Neighbors (kNN) Algorithm in Python – Real Python

Description: In this tutorial, you'll learn all about the k-Nearest Neighbors (kNN) algorithm in Python, including how to implement kNN from scratch, kNN hyperparameter tuning, and improving kNN performance using bagging.

Open Graph Description: In this tutorial, you'll learn all about the k-Nearest Neighbors (kNN) algorithm in Python, including how to implement kNN from scratch, kNN hyperparameter tuning, and improving kNN performance using bagging.

Mail addresses
?subject=Python article for you&body=The k-Nearest Neighbors (kNN) Algorithm in Python on Real Python https://realpython.com/knn-python/

Opengraph URL: https://realpython.com/knn-python/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
{
  "@context": "http://schema.org",
  "@type": "Article",
  "headline": "The k-Nearest Neighbors (kNN) Algorithm in Python",
  "image": {
    "@type": "ImageObject",
    "url": "https://files.realpython.com/media/k-Nearest-Neighbors-in-Python-Guide_Watermarked.a2475a6087a3.jpg",
    "width": 1920,
    "height": 1080
  },
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://realpython.com/knn-python/",
    "lastReviewed": "2022-09-01",
    "author": {
      "@type": "Person",
      "name": "Joos Korstanje",
      "image": "https://realpython.com/cdn-cgi/image/width=1500,height=1500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/real-python-logo-square.28474fda9228.png",
      "url": "https://realpython.com/team/jkorstanje/",
      "affiliation": {
        "@type": "Organization",
        "@id": "https://realpython.com/#organization",
        "name": "Real Python",
        "url": "https://realpython.com",
        "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
      }
    },
    "reviewedBy": [
      {
        "@type": "Person",
        "name": "Aldren Santos",
        "image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Aldren_Santos_Real_Python.6b0861d8b841.png",
        "url": "https://realpython.com/team/asantos/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Bartosz Zaczy\u0144ski",
        "image": "https://realpython.com/cdn-cgi/image/width=1694,height=1694,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/coders_lab_2109368.259b1599fbee.jpg",
        "url": "https://realpython.com/team/bzaczynski/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "David Amos",
        "image": "https://realpython.com/cdn-cgi/image/width=400,height=400,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/me-small.f5f49f1c48e1.jpg",
        "url": "https://realpython.com/team/damos/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Geir Arne Hjelle",
        "image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/gahjelle.470149ee709e.jpg",
        "url": "https://realpython.com/team/gahjelle/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Joanna Jablonski",
        "image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/jjablonksi-avatar.e37c4f83308e.jpg",
        "url": "https://realpython.com/team/jjablonski/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Jacob Schmitt",
        "image": "https://realpython.com/cdn-cgi/image/width=400,height=400,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/profile-small_js.2f4d0d8da1ca.jpg",
        "url": "https://realpython.com/team/jschmitt/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      }
    ]
  },
  "datePublished": "2021-04-07T14:00:00+00:00",
  "dateModified": "2022-09-01T07:39:19.792993+00:00",
  "publisher": {
    "@type": "Organization",
    "@id": "https://realpython.com/#organization",
    "name": "Real Python",
    "url": "https://realpython.com",
    "logo": {
      "@type": "ImageObject",
      "url": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png",
      "width": 512,
      "height": 512
    },
    "description": "Real Python is a leading provider of online Python education and one of the largest language-specific online communities for software developers. It publishes high-quality learning resources, such as tutorials, books, and courses to an audience of millions of developers, data scientists, and machine learning engineers each month.",
    "slogan": "Become a Python Expert",
    "email": "info@realpython.com",
    "sameAs": [
      "https://github.com/realpython",
      "https://www.youtube.com/realpython",
      "https://twitter.com/realpython",
      "https://x.com/realpython",
      "https://www.linkedin.com/company/realpython-com/",
      "https://www.facebook.com/learnrealpython",
      "https://www.instagram.com/realpython",
      "https://www.tiktok.com/@realpython.com"
    ]
  },
  "author": {
    "@type": "Person",
    "name": "Joos Korstanje",
    "image": "https://realpython.com/cdn-cgi/image/width=1500,height=1500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/real-python-logo-square.28474fda9228.png",
    "url": "https://realpython.com/team/jkorstanje/",
    "affiliation": {
      "@type": "Organization",
      "@id": "https://realpython.com/#organization",
      "name": "Real Python",
      "url": "https://realpython.com",
      "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
    }
  },
  "description": "In this tutorial, you'll learn all about the k-Nearest Neighbors (kNN) algorithm in Python, including how to implement kNN from scratch, kNN hyperparameter tuning, and improving kNN performance using bagging."
}

authorReal Python
twitter:cardsummary_large_image
twitter:imagehttps://files.realpython.com/media/k-Nearest-Neighbors-in-Python-Guide_Watermarked.a2475a6087a3.jpg
og:imagehttps://files.realpython.com/media/k-Nearest-Neighbors-in-Python-Guide_Watermarked.a2475a6087a3.jpg
twitter:creator@realpython
og:typearticle

Links:

https://realpython.com/
Start Herehttps://realpython.com/start-here/
Learn Python https://realpython.com/knn-python/
Python Tutorials →In-depth articles and video courseshttps://realpython.com/search?kind=article&kind=course&order=newest
Learning Paths →Guided study plans for accelerated learninghttps://realpython.com/learning-paths/
Quizzes & Exercises →Check your learning progresshttps://realpython.com/quizzes/
Browse Topics →Focus on a specific area or skill levelhttps://realpython.com/tutorials/all/
Community Chat →Learn with other Pythonistashttps://realpython.com/community/
Office Hours →Live Q&A calls with Python expertshttps://realpython.com/office-hours/
Podcast →Hear what’s new in the world of Pythonhttps://realpython.com/podcasts/rpp/
Books →Round out your knowledge and learn offlinehttps://realpython.com/products/books/
Reference →Concise definitions for common Python termshttps://realpython.com/ref/
Code Mentor →BetaPersonalized code assistance & learning toolshttps://realpython.com/mentor/
Unlock All Content →https://realpython.com/account/join/
More https://realpython.com/knn-python/
Learner Storieshttps://realpython.com/learner-stories/
Python Newsletterhttps://realpython.com/newsletter/
Python Job Boardhttps://www.pythonjobshq.com
Meet the Teamhttps://realpython.com/team/
Become a Tutorial Writerhttps://realpython.com/write-for-us/
Become a Video Instructorhttps://realpython.com/become-an-instructor/
Searchhttps://realpython.com/search
https://realpython.com/search
Joinhttps://realpython.com/account/join/
Sign‑Inhttps://realpython.com/account/login/?next=%2Fknn-python%2F
Browse Topicshttps://realpython.com/tutorials/all/
Guided Learning Pathshttps://realpython.com/learning-paths/
Basicshttps://realpython.com/search?level=basics
Intermediatehttps://realpython.com/search?level=intermediate
Advancedhttps://realpython.com/search?level=advanced
aihttps://realpython.com/tutorials/ai/
algorithmshttps://realpython.com/tutorials/algorithms/
apihttps://realpython.com/tutorials/api/
best-practiceshttps://realpython.com/tutorials/best-practices/
careerhttps://realpython.com/tutorials/career/
communityhttps://realpython.com/tutorials/community/
databaseshttps://realpython.com/tutorials/databases/
data-sciencehttps://realpython.com/tutorials/data-science/
data-structureshttps://realpython.com/tutorials/data-structures/
data-vizhttps://realpython.com/tutorials/data-viz/
devopshttps://realpython.com/tutorials/devops/
djangohttps://realpython.com/tutorials/django/
dockerhttps://realpython.com/tutorials/docker/
editorshttps://realpython.com/tutorials/editors/
flaskhttps://realpython.com/tutorials/flask/
front-endhttps://realpython.com/tutorials/front-end/
gamedevhttps://realpython.com/tutorials/gamedev/
guihttps://realpython.com/tutorials/gui/
machine-learninghttps://realpython.com/tutorials/machine-learning/
newshttps://realpython.com/tutorials/news/
numpyhttps://realpython.com/tutorials/numpy/
projectshttps://realpython.com/tutorials/projects/
pythonhttps://realpython.com/tutorials/python/
stdlibhttps://realpython.com/tutorials/stdlib/
testinghttps://realpython.com/tutorials/testing/
toolshttps://realpython.com/tutorials/tools/
web-devhttps://realpython.com/tutorials/web-dev/
web-scrapinghttps://realpython.com/tutorials/web-scraping/
Table of Contentshttps://realpython.com/knn-python/#toc
Basics of Machine Learninghttps://realpython.com/knn-python/#basics-of-machine-learning
Distinguishing Features of kNNhttps://realpython.com/knn-python/#distinguishing-features-of-knn
kNN Is a Supervised Machine Learning Algorithmhttps://realpython.com/knn-python/#knn-is-a-supervised-machine-learning-algorithm
kNN Is a Nonlinear Learning Algorithmhttps://realpython.com/knn-python/#knn-is-a-nonlinear-learning-algorithm
kNN Is a Supervised Learner for Both Classification and Regressionhttps://realpython.com/knn-python/#knn-is-a-supervised-learner-for-both-classification-and-regression
kNN Is Fast and Interpretablehttps://realpython.com/knn-python/#knn-is-fast-and-interpretable
Drawbacks of kNNhttps://realpython.com/knn-python/#drawbacks-of-knn
Use kNN to Predict the Age of Sea Slugshttps://realpython.com/knn-python/#use-knn-to-predict-the-age-of-sea-slugs
The Abalone Problem Statementhttps://realpython.com/knn-python/#the-abalone-problem-statement
Importing the Abalone Datasethttps://realpython.com/knn-python/#importing-the-abalone-dataset
Descriptive Statistics From the Abalone Datasethttps://realpython.com/knn-python/#descriptive-statistics-from-the-abalone-dataset
A Step-by-Step kNN From Scratch in Pythonhttps://realpython.com/knn-python/#a-step-by-step-knn-from-scratch-in-python
Plain English Walkthrough of the kNN Algorithmhttps://realpython.com/knn-python/#plain-english-walkthrough-of-the-knn-algorithm
Define “Nearest” Using a Mathematical Definition of Distancehttps://realpython.com/knn-python/#define-nearest-using-a-mathematical-definition-of-distance
Find the k Nearest Neighborshttps://realpython.com/knn-python/#find-the-k-nearest-neighbors
Voting or Averaging of Multiple Neighborshttps://realpython.com/knn-python/#voting-or-averaging-of-multiple-neighbors
Average for Regressionhttps://realpython.com/knn-python/#average-for-regression
Mode for Classificationhttps://realpython.com/knn-python/#mode-for-classification
Fit kNN in Python Using scikit-learnhttps://realpython.com/knn-python/#fit-knn-in-python-using-scikit-learn
Splitting Data Into Training and Test Sets for Model Evaluationhttps://realpython.com/knn-python/#splitting-data-into-training-and-test-sets-for-model-evaluation
Fitting a kNN Regression in scikit-learn to the Abalone Datasethttps://realpython.com/knn-python/#fitting-a-knn-regression-in-scikit-learn-to-the-abalone-dataset
Using scikit-learn to Inspect Model Fithttps://realpython.com/knn-python/#using-scikit-learn-to-inspect-model-fit
Plotting the Fit of Your Modelhttps://realpython.com/knn-python/#plotting-the-fit-of-your-model
Tune and Optimize kNN in Python Using scikit-learnhttps://realpython.com/knn-python/#tune-and-optimize-knn-in-python-using-scikit-learn
Improving kNN Performances in scikit-learn Using GridSearchCVhttps://realpython.com/knn-python/#improving-knn-performances-in-scikit-learn-using-gridsearchcv
Adding Weighted Average of Neighbors Based on Distancehttps://realpython.com/knn-python/#adding-weighted-average-of-neighbors-based-on-distance
Further Improving on kNN in scikit-learn With Bagginghttps://realpython.com/knn-python/#further-improving-on-knn-in-scikit-learn-with-bagging
Comparison of the Four Modelshttps://realpython.com/knn-python/#comparison-of-the-four-models
Conclusionhttps://realpython.com/knn-python/#conclusion
https://realpython.com/feedback/survey/article/knn-python/liked/?from=article-sidebar
https://realpython.com/feedback/survey/article/knn-python/disliked/?from=article-sidebar
Using k-Nearest Neighbors (kNN) in Python 57m · 9 lessons https://realpython.com/courses/knn-python/
Joos Korstanjehttps://realpython.com/knn-python/#author
https://realpython.com/knn-python/#reader-comments
intermediatehttps://realpython.com/tutorials/intermediate/
algorithmshttps://realpython.com/tutorials/algorithms/
data-sciencehttps://realpython.com/tutorials/data-science/
machine-learninghttps://realpython.com/tutorials/machine-learning/
Basics of Machine Learninghttps://realpython.com/knn-python/#basics-of-machine-learning
Distinguishing Features of kNNhttps://realpython.com/knn-python/#distinguishing-features-of-knn
kNN Is a Supervised Machine Learning Algorithmhttps://realpython.com/knn-python/#knn-is-a-supervised-machine-learning-algorithm
kNN Is a Nonlinear Learning Algorithmhttps://realpython.com/knn-python/#knn-is-a-nonlinear-learning-algorithm
kNN Is a Supervised Learner for Both Classification and Regressionhttps://realpython.com/knn-python/#knn-is-a-supervised-learner-for-both-classification-and-regression
kNN Is Fast and Interpretablehttps://realpython.com/knn-python/#knn-is-fast-and-interpretable
Drawbacks of kNNhttps://realpython.com/knn-python/#drawbacks-of-knn
Use kNN to Predict the Age of Sea Slugshttps://realpython.com/knn-python/#use-knn-to-predict-the-age-of-sea-slugs
The Abalone Problem Statementhttps://realpython.com/knn-python/#the-abalone-problem-statement
Importing the Abalone Datasethttps://realpython.com/knn-python/#importing-the-abalone-dataset
Descriptive Statistics From the Abalone Datasethttps://realpython.com/knn-python/#descriptive-statistics-from-the-abalone-dataset
A Step-by-Step kNN From Scratch in Pythonhttps://realpython.com/knn-python/#a-step-by-step-knn-from-scratch-in-python
Plain English Walkthrough of the kNN Algorithmhttps://realpython.com/knn-python/#plain-english-walkthrough-of-the-knn-algorithm
Define “Nearest” Using a Mathematical Definition of Distancehttps://realpython.com/knn-python/#define-nearest-using-a-mathematical-definition-of-distance
Find the k Nearest Neighborshttps://realpython.com/knn-python/#find-the-k-nearest-neighbors
Voting or Averaging of Multiple Neighborshttps://realpython.com/knn-python/#voting-or-averaging-of-multiple-neighbors
Average for Regressionhttps://realpython.com/knn-python/#average-for-regression
Mode for Classificationhttps://realpython.com/knn-python/#mode-for-classification
Fit kNN in Python Using scikit-learnhttps://realpython.com/knn-python/#fit-knn-in-python-using-scikit-learn
Splitting Data Into Training and Test Sets for Model Evaluationhttps://realpython.com/knn-python/#splitting-data-into-training-and-test-sets-for-model-evaluation
Fitting a kNN Regression in scikit-learn to the Abalone Datasethttps://realpython.com/knn-python/#fitting-a-knn-regression-in-scikit-learn-to-the-abalone-dataset
Using scikit-learn to Inspect Model Fithttps://realpython.com/knn-python/#using-scikit-learn-to-inspect-model-fit
Plotting the Fit of Your Modelhttps://realpython.com/knn-python/#plotting-the-fit-of-your-model
Tune and Optimize kNN in Python Using scikit-learnhttps://realpython.com/knn-python/#tune-and-optimize-knn-in-python-using-scikit-learn
Improving kNN Performances in scikit-learn Using GridSearchCVhttps://realpython.com/knn-python/#improving-knn-performances-in-scikit-learn-using-gridsearchcv
Adding Weighted Average of Neighbors Based on Distancehttps://realpython.com/knn-python/#adding-weighted-average-of-neighbors-based-on-distance
Further Improving on kNN in scikit-learn With Bagginghttps://realpython.com/knn-python/#further-improving-on-knn-in-scikit-learn-with-bagging
Comparison of the Four Modelshttps://realpython.com/knn-python/#comparison-of-the-four-models
Conclusionhttps://realpython.com/knn-python/#conclusion
Remove adshttps://realpython.com/account/join/
Using k-Nearest Neighbors (kNN) in Pythonhttps://realpython.com/courses/knn-python/
machine learninghttps://realpython.com/learning-paths/machine-learning-python/
NumPyhttps://realpython.com/numpy-tutorial/
scikit-learnhttps://scikit-learn.org/stable/
Click here to get access to a free NumPy Resources Guidehttps://realpython.com/bonus/numpy-learning-guide/
https://realpython.com/knn-python/#basics-of-machine-learning
https://files.realpython.com/media/knn_01_MLgeneral_wide.74e5e2dc1094.png
linear modelhttps://en.wikipedia.org/wiki/Linear_model
linear functionhttps://en.wikipedia.org/wiki/Linear_function
Remove adshttps://realpython.com/account/join/
https://realpython.com/knn-python/#distinguishing-features-of-knn
linear regressionhttps://realpython.com/linear-regression-in-python/
https://realpython.com/knn-python/#knn-is-a-supervised-machine-learning-algorithm
https://files.realpython.com/media/knn_02_MLsupervised_wide.aa50e6348ca4.png
https://files.realpython.com/media/knn_03_MLunsupervised_wide.a6fd142b42de.png
K-Means Clustering in Python: A Practical Guidehttps://realpython.com/k-means-clustering-python/
https://realpython.com/knn-python/#knn-is-a-nonlinear-learning-algorithm
hyperplaneshttps://en.wikipedia.org/wiki/Hyperplane
https://files.realpython.com/media/knn_04_MLlinear_wide.05d1160927c7.png
https://files.realpython.com/media/knn_05_MLnonlinear_wide.5f554e71c368.png
Remove adshttps://realpython.com/account/join/
https://realpython.com/knn-python/#knn-is-a-supervised-learner-for-both-classification-and-regression
iris datasethttps://en.wikipedia.org/wiki/Iris_flower_data_set
logistic regressionhttps://realpython.com/logistic-regression-python/
Housing Prices Challenge on Kagglehttps://www.kaggle.com/c/house-prices-advanced-regression-techniques
https://files.realpython.com/media/knn_06_MLclassificationregression.6029d11323aa.png
https://realpython.com/knn-python/#knn-is-fast-and-interpretable
artificial intelligencehttps://realpython.com/python-ai-neural-network/
neural networkshttps://realpython.com/pytorch-vs-tensorflow/
https://realpython.com/knn-python/#drawbacks-of-knn
natural language processinghttps://realpython.com/natural-language-processing-spacy-python/
https://realpython.com/knn-python/#use-knn-to-predict-the-age-of-sea-slugs
https://files.realpython.com/media/LivingAbalone.b5330a55f159.jfif
Image sourcehttps://en.wikipedia.org/wiki/File:LivingAbalone.JPG
the abalone Wikipedia pagehttps://en.wikipedia.org/wiki/Abalone
Remove adshttps://realpython.com/account/join/
https://realpython.com/knn-python/#the-abalone-problem-statement
https://realpython.com/knn-python/#importing-the-abalone-dataset
Abalone Datasethttps://archive.ics.uci.edu/ml/datasets/abalone
pandashttps://realpython.com/learning-paths/pandas-data-science/
Anacondahttps://anaconda.com/
Setting Up Python for Machine Learning on Windowshttps://realpython.com/python-windows-machine-learning-setup/
importhttps://realpython.com/python-import/
DataFramehttps://realpython.com/pandas-dataframe/
abalone.nameshttps://archive.ics.uci.edu/ml/machine-learning-databases/abalone/
https://realpython.com/knn-python/#descriptive-statistics-from-the-abalone-dataset
histogramhttps://realpython.com/python-histograms/
pandas plotting functionalityhttps://realpython.com/pandas-plot-python/
https://files.realpython.com/media/rings_histogram.5b9d67ebae30.png
correlationhttps://realpython.com/numpy-scipy-pandas-correlation-python/
Using pandas and Python to Explore Your Datasethttps://realpython.com/pandas-python-explore-dataset/
Remove adshttps://realpython.com/account/join/
https://realpython.com/knn-python/#a-step-by-step-knn-from-scratch-in-python
https://realpython.com/knn-python/#plain-english-walkthrough-of-the-knn-algorithm
https://realpython.com/knn-python/#define-nearest-using-a-mathematical-definition-of-distance
Euclidean distancehttps://en.wikipedia.org/wiki/Euclidean_distance
https://files.realpython.com/media/knn_pytagoras.78c35cf28a3d.png
https://files.realpython.com/media/euclidean_distance.5b5fe10e9fa0.png
square roothttps://realpython.com/python-square-root-function/
Pythagorean theoremhttps://en.wikipedia.org/wiki/Pythagorean_theorem
Remove adshttps://realpython.com/account/join/
https://realpython.com/knn-python/#find-the-k-nearest-neighbors
https://realpython.com/knn-python/#voting-or-averaging-of-multiple-neighbors
Remove adshttps://realpython.com/account/join/
https://realpython.com/knn-python/#average-for-regression
https://realpython.com/knn-python/#mode-for-classification
SciPyhttps://realpython.com/python-scipy-cluster-optimize/
https://realpython.com/knn-python/#fit-knn-in-python-using-scikit-learn
https://realpython.com/knn-python/#splitting-data-into-training-and-test-sets-for-model-evaluation
scikit-learn’s built-in train_test_split()https://realpython.com/train-test-split-python-data/
Remove adshttps://realpython.com/account/join/
https://realpython.com/knn-python/#fitting-a-knn-regression-in-scikit-learn-to-the-abalone-dataset
https://realpython.com/knn-python/#using-scikit-learn-to-inspect-model-fit
root-mean-square error (RMSE)https://en.wikipedia.org/wiki/Root-mean-square_deviation
overfittinghttps://en.wikipedia.org/wiki/Overfitting
https://realpython.com/knn-python/#plotting-the-fit-of-your-model
Seabornhttps://seaborn.pydata.org/
Python Plotting With Matplotlibhttps://realpython.com/python-matplotlib-guide/
https://files.realpython.com/media/first_scatter.dd9e9b8454b9.png
https://files.realpython.com/media/second_scatter.8124c6a8d55d.png
Remove adshttps://realpython.com/account/join/
https://realpython.com/knn-python/#tune-and-optimize-knn-in-python-using-scikit-learn
data wranglinghttps://en.wikipedia.org/wiki/Data_wrangling
https://realpython.com/knn-python/#improving-knn-performances-in-scikit-learn-using-gridsearchcv
https://realpython.com/knn-python/#adding-weighted-average-of-neighbors-based-on-distance
Remove adshttps://realpython.com/account/join/
https://realpython.com/knn-python/#further-improving-on-knn-in-scikit-learn-with-bagging
https://realpython.com/knn-python/#comparison-of-the-four-models
https://realpython.com/knn-python/#conclusion
Machine Learning Learning Pathhttps://realpython.com/learning-paths/machine-learning-python/
https://realpython.com/feedback/survey/article/knn-python/liked/?from=article-footer
https://realpython.com/feedback/survey/article/knn-python/disliked/?from=article-footer
Using k-Nearest Neighbors (kNN) in Pythonhttps://realpython.com/courses/knn-python/
https://realpython.com/team/jkorstanje/
» More about Jooshttps://realpython.com/team/jkorstanje/
https://realpython.com/team/asantos/
Aldrenhttps://realpython.com/team/asantos/
https://realpython.com/team/bzaczynski/
Bartoszhttps://realpython.com/team/bzaczynski/
https://realpython.com/team/damos/
Davidhttps://realpython.com/team/damos/
https://realpython.com/team/gahjelle/
Geir Arnehttps://realpython.com/team/gahjelle/
https://realpython.com/team/jjablonski/
Joannahttps://realpython.com/team/jjablonski/
https://realpython.com/team/jschmitt/
Jacobhttps://realpython.com/team/jschmitt/
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=knn-python
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=knn-python
https://realpython.com/feedback/survey/article/knn-python/liked/?from=article-comments
https://realpython.com/feedback/survey/article/knn-python/disliked/?from=article-comments
LinkedInhttps://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Frealpython.com%2Fknn-python%2F
Twitterhttps://twitter.com/intent/tweet/?text=Interesting%20Python%20article%20on%20%40realpython%3A%20The%20k-Nearest%20Neighbors%20%28kNN%29%20Algorithm%20in%20Python&url=https%3A%2F%2Frealpython.com%2Fknn-python%2F
Blueskyhttps://bsky.app/intent/compose?text=Interesting%20Python%20article%20on%20%40realpython.com%3A%20The%20k-Nearest%20Neighbors%20%28kNN%29%20Algorithm%20in%20Python%20https%3A%2F%2Frealpython.com%2Fknn-python%2F
Facebookhttps://facebook.com/sharer/sharer.php?u=https%3A%2F%2Frealpython.com%2Fknn-python%2F
Get tips for asking good questionshttps://realpython.com/python-beginner-tips/#tip-9-ask-good-questions
get answers to common questions in our support portalhttps://support.realpython.com
Real Python Community Chathttps://realpython.com/community/
“Office Hours” Live Q&A Sessionhttps://realpython.com/office-hours/
intermediatehttps://realpython.com/tutorials/intermediate/
algorithmshttps://realpython.com/tutorials/algorithms/
data-sciencehttps://realpython.com/tutorials/data-science/
machine-learninghttps://realpython.com/tutorials/machine-learning/
Using k-Nearest Neighbors (kNN) in Pythonhttps://realpython.com/courses/knn-python/?utm_source=realpython&utm_medium=web&utm_campaign=related-course&utm_content=knn-python
Python AI: How to Build a Neural Network & Make Predictionshttps://realpython.com/python-ai-neural-network/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=knn-python
K-Means Clustering in Python: A Practical Guidehttps://realpython.com/k-means-clustering-python/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=knn-python
Logistic Regression in Pythonhttps://realpython.com/logistic-regression-python/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=knn-python
Linear Regression in Pythonhttps://realpython.com/linear-regression-in-python/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=knn-python
https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fknn-python%2F
Continue »https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fknn-python%2F
Sign-Inhttps://realpython.com/account/login/?next=/knn-python/
Start Herehttps://realpython.com/start-here/
Learning Resourceshttps://realpython.com/search
Code Mentorhttps://realpython.com/mentor/
Python Referencehttps://realpython.com/ref/
Python Cheat Sheethttps://realpython.com/cheatsheets/python/
Support Centerhttps://support.realpython.com/
Learning Pathshttps://realpython.com/learning-paths/
Quizzes & Exerciseshttps://realpython.com/quizzes/
Browse Topicshttps://realpython.com/tutorials/all/
Live Courseshttps://realpython.com/live/
Bookshttps://realpython.com/books/
Podcasthttps://realpython.com/podcasts/rpp/
Newsletterhttps://realpython.com/newsletter/
Community Chathttps://realpython.com/community/
Office Hourshttps://realpython.com/office-hours/
Learner Storieshttps://realpython.com/learner-stories/
Plans & Pricinghttps://realpython.com/account/join/
Team Planshttps://realpython.com/account/join-team/
For Businesshttps://realpython.com/account/join-team/inquiry/
For Schoolshttps://realpython.com/account/join-team/education-inquiry/
Reviewshttps://realpython.com/learner-stories/
About Ushttps://realpython.com/about/
Teamhttps://realpython.com/team/
Mission & Valueshttps://realpython.com/mission/
Editorial Guidelineshttps://realpython.com/editorial-guidelines/
Sponsorshipshttps://realpython.com/sponsorships/
Careershttps://realpython.workable.com
Press Kithttps://realpython.com/media-kit/
Merchhttps://realpython.com/merch
https://www.youtube.com/realpython
https://x.com/realpython
https://www.linkedin.com/company/realpython-com
https://www.facebook.com/LearnRealPython
https://github.com/realpython/
Privacy Policyhttps://realpython.com/privacy-policy/
Terms of Usehttps://realpython.com/terms/
Securityhttps://realpython.com/security/
Contacthttps://realpython.com/contact/
https://realpython.com/

Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover

Robots: max-image-preview:large


URLs of crawlers that visited me.