What are tune ensemble and blend models functions in PyCaret

In this recipe, we shall learn about the tune model, ensemble model and blend models functions in the classification model in PyCaret.

Recipe Objective - What are the tune_model, ensemble_model, and blend_model functions in the classification model in PyCaret?

PyCaret provides tune_model, ensemble_model and blend_models functions in the classification module.

For more related projects:-

https://www.dezyre.com/projects/data-science-projects/data-science-projects-in-python
https://www.dezyre.com/projects/data-science-projects/machine-learning-projects-in-python

Tune Model function with Example:

PyCaret provides "pycaret.classification.tune_model()" function. Tune model function tunes the hyperparameters of a given estimator.

from pycaret.datasets import get_data
iris = get_data('iris')
# importing classification module
from pycaret.classification import *
# initialize setup
setup_name = setup(data = iris, target = 'species')
# logistic regression
log_reg = create_model('lr')
tuned_log_reg = tune_model(log_reg)
tuned_log_reg

ensemble_model function with Example:

PyCaret provides "pycaret.classification.ensemble_models()" function. Ensemble model function ensembles a given estimator.

The output of this function is a scoring grid with CV scores by fold.

from pycaret.datasets import get_data
iris = get_data('iris')
# importing classification module
from pycaret.classification import *
# initialize setup
setup_name = setup(data = iris, target = 'species')
# SVM model
svm = create_model('svm')
bagged_svm = ensemble_model(svm, method = 'Bagging')
bagged_svm

blend_models function with Example:

PyCaret provides "pycaret.classification.blend_models()" function. blend_models function trains a Soft Voting / Majority Rule classifier for select models passed in the "estimator_list" parameters.

The output of this function is a scoring grid with CV scores by fold.

from pycaret.datasets import get_data
iris = get_data('iris')
# importing classification module
from pycaret.classification import *
# initialize setup
setup_name = setup(data = iris, target = 'species')
top3 = compare_models(n_select = 3)
blender = blend_models(top3)
blender

What Users are saying..

profile image

Jingwei Li

Graduate Research assistance at Stony Brook University
linkedin profile url

ProjectPro is an awesome platform that helps me learn much hands-on industrial experience with a step-by-step walkthrough of projects. There are two primary paths to learn: Data Science and Big Data.... Read More

Relevant Projects

Loan Eligibility Prediction in Python using H2O.ai
In this loan prediction project you will build predictive models in Python using H2O.ai to predict if an applicant is able to repay the loan or not.

NLP Project for Beginners on Text Processing and Classification
This Project Explains the Basic Text Preprocessing and How to Build a Classification Model in Python

End-to-End Snowflake Healthcare Analytics Project on AWS-1
In this Snowflake Healthcare Analytics Project, you will leverage Snowflake on AWS to predict patient length of stay (LOS) in hospitals. The prediction of LOS can help in efficient resource allocation, lower the risk of staff/visitor infections, and improve overall hospital functioning.

Build a Multi Touch Attribution Machine Learning Model in Python
Identifying the ROI on marketing campaigns is an essential KPI for any business. In this ML project, you will learn to build a Multi Touch Attribution Model in Python to identify the ROI of various marketing efforts and their impact on conversions or sales..

Build Regression Models in Python for House Price Prediction
In this Machine Learning Regression project, you will build and evaluate various regression models in Python for house price prediction.

Build a Credit Default Risk Prediction Model with LightGBM
In this Machine Learning Project, you will build a classification model for default prediction with LightGBM.

NLP and Deep Learning For Fake News Classification in Python
In this project you will use Python to implement various machine learning methods( RNN, LSTM, GRU) for fake news classification.

Create Your First Chatbot with RASA NLU Model and Python
Learn the basic aspects of chatbot development and open source conversational AI RASA to create a simple AI powered chatbot on your own.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

Learn How to Build a Linear Regression Model in PyTorch
In this Machine Learning Project, you will learn how to build a simple linear regression model in PyTorch to predict the number of days subscribed.