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

Savvy Sahai

Data Science Intern, Capgemini
linkedin profile url

As a student looking to break into the field of data engineering and data science, one can get really confused as to which path to take. Very few ways to do it are Google, YouTube, etc. I was one of... Read More

Relevant Projects

ML Model Deployment on AWS for Customer Churn Prediction
MLOps Project-Deploy Machine Learning Model to Production Python on AWS for Customer Churn Prediction

Time Series Forecasting Project-Building ARIMA Model in Python
Build a time series ARIMA model in Python to forecast the use of arrival rate density to support staffing decisions at call centres.

Build an AI Chatbot from Scratch using Keras Sequential Model
In this NLP Project, you will learn how to build an AI Chatbot from Scratch using Keras Sequential Model.

Time Series Analysis with Facebook Prophet Python and Cesium
Time Series Analysis Project - Use the Facebook Prophet and Cesium Open Source Library for Time Series Forecasting in Python

NLP Project to Build a Resume Parser in Python using Spacy
Use the popular Spacy NLP python library for OCR and text classification to build a Resume Parser in Python.

Loan Default Prediction Project using Explainable AI ML Models
Loan Default Prediction Project that employs sophisticated machine learning models, such as XGBoost and Random Forest and delves deep into the realm of Explainable AI, ensuring every prediction is transparent and understandable.

Machine Learning Project to Forecast Rossmann Store Sales
In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

Classification Projects on Machine Learning for Beginners - 1
Classification ML Project for Beginners - A Hands-On Approach to Implementing Different Types of Classification Algorithms in Machine Learning for Predictive Modelling

Build a Text Generator Model using Amazon SageMaker
In this Deep Learning Project, you will train a Text Generator Model on Amazon Reviews Dataset using LSTM Algorithm in PyTorch and deploy it on Amazon SageMaker.

Loan Eligibility Prediction Project using Machine learning on GCP
Loan Eligibility Prediction Project - Use SQL and Python to build a predictive model on GCP to determine whether an application requesting loan is eligible or not.