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
Hands-On Gradient Boosting with XGBoost and scikit-learn

You're reading from   Hands-On Gradient Boosting with XGBoost and scikit-learn Perform accessible machine learning and extreme gradient boosting with Python

Arrow left icon
Product type Paperback
Published in Oct 2020
Publisher Packt
ISBN-13 9781839218354
Length 310 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Corey Wade Corey Wade
Author Profile Icon Corey Wade
Corey Wade
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Section 1: Bagging and Boosting
2. Chapter 1: Machine Learning Landscape FREE CHAPTER 3. Chapter 2: Decision Trees in Depth 4. Chapter 3: Bagging with Random Forests 5. Chapter 4: From Gradient Boosting to XGBoost 6. Section 2: XGBoost
7. Chapter 5: XGBoost Unveiled 8. Chapter 6: XGBoost Hyperparameters 9. Chapter 7: Discovering Exoplanets with XGBoost 10. Section 3: Advanced XGBoost
11. Chapter 8: XGBoost Alternative Base Learners 12. Chapter 9: XGBoost Kaggle Masters 13. Chapter 10: XGBoost Model Deployment 14. Other Books You May Enjoy

Building a machine learning pipeline

Completing the machine learning pipeline requires adding the machine learning model to the previous pipeline. You need a machine learning tuple after NullValueImputer and SparseMatrix as follows:

full_pipeline = Pipeline([('null_imputer', NullValueImputer()),  ('sparse', SparseMatrix()), 
('xgb', XGBRegressor(max_depth=1, min_child_weight=5, subsample=0.6, colsample_bytree=0.9, colsample_bylevel=0.9, colsample_bynode=0.8, missing=-999.0))]) 

This pipeline is now complete with a machine learning model, and it can be fit on any X, y combination, as follows:

full_pipeline.fit(X, y)

Now you can make predictions on any data whose target column is unknown:

new_data = X_test
full_pipeline.predict(new_data)

Here are the first few rows of the expected output:

array([13.55908  ,  8.314051 , 11.078157 , 14.114085 , 12.2938385, 11.374797 , 13.9611025, 12.025812 , 10.80344 ...
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