Stack model, plot model, evaluate model functions in PyCaret

In this recipe, we shall see what are stack models plot model and evaluate model functions in the classification model in PyCaret.

Recipe Objective - What are stack_models, plot_model, and evaluate_model functions in the classification model in PyCaret?

PyCaret provides stack_models, plot_model and evaluate_model functions in the classification module.

 

For more related projects:

https://www.dezyre.com/projects/data-science-projects/tensorflow-projects
https://www.dezyre.com/projects/data-science-projects/keras-deep-learning-projects

stack_models function with Example:

PyCaret provides "pycaret.classification.stack_models()" function. Stack models function trains a meta-model over select estimators passed in the estimator_list parameter

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 *
set_up = setup(data = iris, target = 'species')
comp_top3 = compare_models(n_select = 3)
stack = stack_models(comp_top3)
stack

plot_model function with Example:

PyCaret provides "pycaret.classification.plot_model()" function. Plot model function analyzes the performance of a trained model on holdout set.

from pycaret.datasets import get_data
iris = get_data('iris')
# importing classification module
from pycaret.classification import *
set_up = setup(data = iris, target = 'species')
# logistic regression
log_reg = create_model('lr')
# area under the curve
plot_model(log_reg, plot = 'auc')

List of plots in PyCaret:

‘auc’ - Area Under the Curve

‘threshold’ - Discrimination Threshold

‘pr’ - Precision-Recall Curve

‘confusion_matrix’ - Confusion Matrix

‘error’ - Class Prediction Error

‘class_report’ - Classification Report

‘boundary’ - Decision Boundary

‘rfe’ - Recursive Feature Selection

‘learning’ - Learning Curve

‘manifold’ - Manifold Learning

‘calibration’ - Calibration Curve

‘vc’ - Validation Curve

‘dimension’ - Dimension Learning

‘feature’ - Feature Importance

‘feature_all’ - Feature Importance

‘parameter’ - Model Hyperparameter

‘lift’ - Lift Curve

‘gain’ - Gain Chart

‘tree’ - Decision Tree

‘ks’ - KS Statistic Plot

evaluate_model function with Example:

PyCaret provides "pycaret.classification.evaluate_model()" function. evaluate_model function displays a user interface for analyzing performance of a trained model.

from pycaret.datasets import get_data
iris = get_data('iris')
# importing classification module
from pycaret.classification import *
set_up = setup(data = iris, target = 'species')
# creating model
svm = create_model('svm')
# evaluate_model function
evaluate_model(svm)

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

Expedia Hotel Recommendations Data Science Project
In this data science project, you will contextualize customer data and predict the likelihood a customer will stay at 100 different hotel groups.

Abstractive Text Summarization using Transformers-BART Model
Deep Learning Project to implement an Abstractive Text Summarizer using Google's Transformers-BART Model to generate news article headlines.

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.

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.

Langchain Project for Customer Support App in Python
In this LLM Project, you will learn how to enhance customer support interactions through Large Language Models (LLMs), enabling intelligent, context-aware responses. This Langchain project aims to seamlessly integrate LLM technology with databases, PDF knowledge bases, and audio processing agents to create a comprehensive customer support application.

Machine Learning project for Retail Price Optimization
In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

Build a Text Classification Model with Attention Mechanism NLP
In this NLP Project, you will learn to build a multi class text classification model with attention mechanism.

Build an End-to-End AWS SageMaker Classification Model
MLOps on AWS SageMaker -Learn to Build an End-to-End Classification Model on SageMaker to predict a patient’s cause of death.

OpenCV Project for Beginners to Learn Computer Vision Basics
In this OpenCV project, you will learn computer vision basics and the fundamentals of OpenCV library using Python.

Build Piecewise and Spline Regression Models in Python
In this Regression Project, you will learn how to build a piecewise and spline regression model from scratch in Python to predict the points scored by a sports team.