Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Machine Learning with scikit-learn Quick Start Guide

You're reading from   Machine Learning with scikit-learn Quick Start Guide Classification, regression, and clustering techniques in Python

Arrow left icon
Product type Paperback
Published in Oct 2018
Publisher Packt
ISBN-13 9781789343700
Length 172 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Kevin Jolly Kevin Jolly
Author Profile Icon Kevin Jolly
Kevin Jolly
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Introducing Machine Learning with scikit-learn 2. Predicting Categories with K-Nearest Neighbors FREE CHAPTER 3. Predicting Categories with Logistic Regression 4. Predicting Categories with Naive Bayes and SVMs 5. Predicting Numeric Outcomes with Linear Regression 6. Classification and Regression with Trees 7. Clustering Data with Unsupervised Machine Learning 8. Performance Evaluation Methods 9. Other Books You May Enjoy

The k-NN algorithm

Mathematically speaking, the k-NN algorithm is one of the most simple machine learning algorithms out there. See the following diagram for a visual overview of how it works:

How k-NN works under the hood

The stars in the preceding diagram represent new data points. If we built a k-NN algorithm with three neighbors, then the stars would search for the three data points that are closest to it.

In the lower-left case, the star sees two triangles and one circle. Therefore, the algorithm would classify the star as a triangle since the number of triangles was greater than the number of circles.

In the upper-right case, the star sees two circles and one circle. Therefore, the algorithm will classify the star as a circle since the number of circles was greater than the number of triangles.

The real algorithm does this in a very probabilistic manner and picks the...

You have been reading a chapter from
Machine Learning with scikit-learn Quick Start Guide
Published in: Oct 2018
Publisher: Packt
ISBN-13: 9781789343700
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime