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
Feature Engineering Made Easy

You're reading from   Feature Engineering Made Easy Identify unique features from your dataset in order to build powerful machine learning systems

Arrow left icon
Product type Paperback
Published in Jan 2018
Publisher Packt
ISBN-13 9781787287600
Length 316 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Divya Susarla Divya Susarla
Author Profile Icon Divya Susarla
Divya Susarla
Sinan Ozdemir Sinan Ozdemir
Author Profile Icon Sinan Ozdemir
Sinan Ozdemir
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Introduction to Feature Engineering 2. Feature Understanding – What's in My Dataset? FREE CHAPTER 3. Feature Improvement - Cleaning Datasets 4. Feature Construction 5. Feature Selection 6. Feature Transformations 7. Feature Learning 8. Case Studies 9. Other Books You May Enjoy

How centering and scaling data affects PCA


As with many of the transformations that we have worked with previously in this text, the scaling of features tends to matter a great deal to the transformations. PCA is no different. Previously, we mentioned that the scikit-learn version of PCA automatically centers data in the prediction phase, but why doesn't it do so at the fitting time? If the scikit-learn PCA module goes through the trouble of centering data in the predict method, why doesn't it do so while calculating the eigenvectors? The hypothesis here is that centering data doesn't affect the principal components. Let's test this:

  1. Let's import out StandardScaler module from scikit-learn and center the iris dataset:
# import our scaling module
 from sklearn.preprocessing import StandardScaler
 # center our data, not a full scaling
 X_centered = StandardScaler(with_std=False).fit_transform(iris_X)

 X_centered[:5,]

 array([[-0.74333333, 0.446 , -2.35866667, -0.99866667], [-0.94333333, -0...
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 $19.99/month. Cancel anytime