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

Gautam Vermani

Data Consultant at Confidential
linkedin profile url

Having worked in the field of Data Science, I wanted to explore how I can implement projects in other domains, So I thought of connecting with ProjectPro. A project that helped me absorb this topic... Read More

Relevant Projects

End-to-End Speech Emotion Recognition Project using ANN
Speech Emotion Recognition using RAVDESS Audio Dataset - Build an Artificial Neural Network Model to Classify Audio Data into various Emotions like Sad, Happy, Angry, and Neutral

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..

Word2Vec and FastText Word Embedding with Gensim in Python
In this NLP Project, you will learn how to use the popular topic modelling library Gensim for implementing two state-of-the-art word embedding methods Word2Vec and FastText models.

Recommender System Machine Learning Project for Beginners-4
Collaborative Filtering Recommender System Project - Comparison of different model based and memory based methods to build recommendation system using collaborative filtering.

Deep Learning Project for Text Detection in Images using Python
CV2 Text Detection Code for Images using Python -Build a CRNN deep learning model to predict the single-line text in a given image.

PyTorch Project to Build a GAN Model on MNIST Dataset
In this deep learning project, you will learn how to build a GAN Model on MNIST Dataset for generating new images of handwritten digits.

Deep Learning Project for Time Series Forecasting in Python
Deep Learning for Time Series Forecasting in Python -A Hands-On Approach to Build Deep Learning Models (MLP, CNN, LSTM, and a Hybrid Model CNN-LSTM) on Time Series Data.

Time Series Python Project using Greykite and Neural Prophet
In this time series project, you will forecast Walmart sales over time using the powerful, fast, and flexible time series forecasting library Greykite that helps automate time series problems.

Build a Churn Prediction Model using Ensemble Learning
Learn how to build ensemble machine learning models like Random Forest, Adaboost, and Gradient Boosting for Customer Churn Prediction using Python

Build a Multi-Class Classification Model in Python on Saturn Cloud
In this machine learning classification project, you will build a multi-class classification model in Python on Saturn Cloud to predict the license status of a business.