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

You're reading from  Feature Engineering Made Easy

Product type Book
Published in Jan 2018
Publisher Packt
ISBN-13 9781787287600
Pages 316 pages
Edition 1st Edition
Languages
Authors (2):
Sinan Ozdemir Sinan Ozdemir
Profile icon Sinan Ozdemir
Divya Susarla Divya Susarla
Profile icon Divya Susarla
View More author details
Toc

Table of Contents (14) Chapters close

Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
1. Introduction to Feature Engineering 2. Feature Understanding – What's in My Dataset? 3. Feature Improvement - Cleaning Datasets 4. Feature Construction 5. Feature Selection 6. Feature Transformations 7. Feature Learning 8. Case Studies 1. Other Books You May Enjoy

Imputing categorical features


Now that we have an understanding of the data we are working with, let's take a look at our missing values:

  • To do this, we can use the isnull method available to us in pandas for DataFrames. This method returns a boolean same-sized object indicating if the values are null.
  • We will then sum these to see which columns have missing data:
X.isnull().sum()
>>>>
boolean                1
city                   1
ordinal_column         0
quantitative_column    1
dtype: int64

Here, we can see that three of our columns are missing values. Our course of action will be to impute these missing values.

If you recall, we implemented scikit-learn's Imputer class in a previous chapter to fill in numerical data. Imputer does have a categorical option, most_frequent, however it only works on categorical data that has been encoded as integers.

We may not always want to transform our categorical data this way, as it can change how we interpret the categorical information,...

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