Predict model, finalize model, deploy model functions in PyCaret

In this recipe, we will see what are predict model finalize model and deploy model functions in the classification model in PyCaret through examples.

Recipe Objective - What are predict_model, finalize_model, and deploy_model functions in the classification model in PyCaret?

PyCaret provides predict_model, finalize_model, and deploy_model functions in the classification module.

List of Classification Algorithms in Machine Learning

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


Predict Model function with Example:

PyCaret provides "pycaret.classification.predict_model()" function. Predict model function predicts "Label" and "Score" using a trained model.

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')
pred_holdout = predict_model(log_reg)
pred_holdout

finalize_model function with Example:

PyCaret provides "pycaret.classification.finalize_model()" function. Finalize model function trains a given estimator on the entire dataset including.

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')
final_log_reg = finalize_model(log_reg)
final_log_reg

deploy_model function with Example:

PyCaret provides "pycaret.classification.deploy_model()" function. Deploy model function deploys the transformation pipeline and trained model on cloud.

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')
# sets appropriate credentials for the platform as environment variables
import os
# set your cloud ACCESS_KEY_ID, SECRET_ACCESS_KEY
os.environ["AWS_ACCESS_KEY_ID"] = str("foo")
os.environ["AWS_SECRET_ACCESS_KEY"] = str("bar")
deploy_model(model = lr, model_name = 'lr-for-deployment', platform = 'aws',
    authentication = {'bucket' : 'S3-bucket-name'})

What Users are saying..

profile image

Anand Kumpatla

Sr Data Scientist @ Doubleslash Software Solutions Pvt Ltd
linkedin profile url

ProjectPro is a unique platform and helps many people in the industry to solve real-life problems with a step-by-step walkthrough of projects. A platform with some fantastic resources to gain... Read More

Relevant Projects

Build ARCH and GARCH Models in Time Series using Python
In this Project we will build an ARCH and a GARCH model using Python

Build a Face Recognition System in Python using FaceNet
In this deep learning project, you will build your own face recognition system in Python using OpenCV and FaceNet by extracting features from an image of a person's face.

Multilabel Classification Project for Predicting Shipment Modes
Multilabel Classification Project to build a machine learning model that predicts the appropriate mode of transport for each shipment, using a transport dataset with 2000 unique products. The project explores and compares four different approaches to multilabel classification, including naive independent models, classifier chains, natively multilabel models, and multilabel to multiclass approaches.

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.

A/B Testing Approach for Comparing Performance of ML Models
The objective of this project is to compare the performance of BERT and DistilBERT models for building an efficient Question and Answering system. Using A/B testing approach, we explore the effectiveness and efficiency of both models and determine which one is better suited for Q&A tasks.

Hands-On Approach to Regression Discontinuity Design Python
In this machine learning project, you will learn to implement Regression Discontinuity Design Example in Python to determine the effect of age on Mortality Rate in Python.

Stock Price Prediction Project using LSTM and RNN
Learn how to predict stock prices using RNN and LSTM models. Understand deep learning concepts and apply them to real-world financial data for accurate forecasting.

Avocado Machine Learning Project Python for Price Prediction
In this ML Project, you will use the Avocado dataset to build a machine learning model to predict the average price of avocado which is continuous in nature based on region and varieties of avocado.

Tensorflow Transfer Learning Model for Image Classification
Image Classification Project - Build an Image Classification Model on a Dataset of T-Shirt Images for Binary Classification

Deploy Transformer-BART Model on Paperspace Cloud
In this MLOps Project you will learn how to deploy a Tranaformer BART Model for Abstractive Text Summarization on Paperspace Private Cloud