Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
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

Product type Book
Published in Oct 2018
Publisher Packt
ISBN-13 9781789343700
Pages 172 pages
Edition 1st Edition
Languages
Author (1):
Kevin Jolly Kevin Jolly
Profile icon Kevin Jolly
Toc

Table of Contents (10) Chapters close

Preface 1. Introducing Machine Learning with scikit-learn 2. Predicting Categories with K-Nearest Neighbors 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

Scaling for optimized performance

The k-NN algorithm is an algorithm that works based on distance. When a new data point is thrown into the dataset and the algorithm is given the task of classifying this new data point, it uses distance to check the points that are closest to it.

If we have features that have different ranges of values – for example, feature one has a range between 0 to 800 while feature two has a range between one to five – this distance metric does not make sense anymore. We want all the features to have the same range of values so that the distance metric is on level terms across all features.

One way to do this is to subtract each value of each feature by the mean of that feature and divide by the variance of that feature. This is called standardization:

We can do this for our dataset by using the following code:

from sklearn.preprocessing...
lock icon The rest of the chapter is locked
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 $15.99/month. Cancel anytime