Skip to Content
Hands-On Automated Machine Learning
book

Hands-On Automated Machine Learning

by Sibanjan Das, Umit Mert Cakmak
April 2018
Beginner to intermediate content levelBeginner to intermediate
282 pages
6h 52m
English
Packt Publishing
Content preview from Hands-On Automated Machine Learning

Univariate feature selection

In this method, a statistical test is applied to each feature individually. We retain only the best features according to the test outcome scores.

The following example illustrates the chi-squared statistical test to select the best features from the HR attrition dataset:

#Chi2 Selectorfrom sklearn.feature_selection import SelectKBestfrom sklearn.feature_selection import chi2chi2_model = SelectKBest(score_func=chi2, k=4)X_best_feat = chi2_model.fit_transform(X, Y)# selected features
print('Number of features:', X.shape[1])print('Reduced number of features:',X_best_feat.shape[1])

We can see from the following output that 4 best features were selected. We can change the number of best features to be considered by ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Automated Machine Learning

Automated Machine Learning

Adnan Masood
R: Unleash Machine Learning Techniques

R: Unleash Machine Learning Techniques

Raghav Bali, Dipanjan Sarkar, Brett Lantz, Cory Lesmeister

Publisher Resources

ISBN: 9781788629898Supplemental Content