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

Scikit-learn's PCA


As usual, scikit-learn saves the day by implementing this procedure in an easy to use transformer so that we don't have to go through that manual process each time we wish to use this powerful process:

  1. We can import it from scikit-learn's decomposition module:
# scikit-learn's version of PCA
from sklearn.decomposition import PCA
  1. To mimic the process we performed with the iris dataset, let's instantiate a PCA object with only two components:
# Like any other sklearn module, we first instantiate the class
pca = PCA(n_components=2)
  1. Now, we can fit our PCA to the data:
# fit the PCA to our data
pca.fit(iris_X)
  1. Let's take a look at some of the attributes of the PCA object to see if they match up with what we achieved in our manual process. Let's take a look at the components_ attribute of our object to see if this matches up without the top_2_eigenvectors variable:
pca.components_

array([[ 0.36158968, -0.08226889,  0.85657211,  0.35884393],
       [ 0.65653988,  0.72971237, -0.1757674...
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 €18.99/month. Cancel anytime