save model and load model function in regression in pycaret

This recipe explains the save model load model function in regression in Pycaret. The save model function saves the transformation pipeline and the load model function loads a previously saved pipeline.

Recipe Objective - What are the save_model and load_model functions in the regression model in pycaret?

PyCaret provides the save_model and load_model function in the regression module.

Learn to Implement Customer Churn Prediction Using Machine Learning in Python

For more related projects:-

https://www.projectpro.io/projects/data-science-projects/tensorflow-projects
https://www.projectpro.io/projects/data-science-projects/keras-deep-learning-projects

Save model function with Example:-

PyCaret provides "pycaret.regression.save_model()" function.

The Save model function saves the transformation pipeline and trained model object into the current working directory as a pickle file for later use.

from pycaret.datasets import get_data
bost = get_data('boston')
# importing regression module
from pycaret.regression import *
# initialize setup
set_up = setup(data = bost, target = 'medv')
# logistic regression
log_reg = create_model('lr')
# saving model
save_model(log_reg, 'saved_lr_model')

load_model function with Example:-

PyCaret provides "pycaret.regression.load_model()" function.

The load model function loads a previously saved pipeline.

from pycaret.regression import load_model
saved_lr = load_model('saved_lr_model')
saved_lr

What Users are saying..

profile image

Ed Godalle

Director Data Analytics at EY / EY Tech
linkedin profile url

I am the Director of Data Analytics with over 10+ years of IT experience. I have a background in SQL, Python, and Big Data working with Accenture, IBM, and Infosys. I am looking to enhance my skills... Read More

Relevant Projects

Build Time Series Models for Gaussian Processes in Python
Time Series Project - A hands-on approach to Gaussian Processes for Time Series Modelling in Python

AWS MLOps Project to Deploy Multiple Linear Regression Model
Build and Deploy a Multiple Linear Regression Model in Python on AWS

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.

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.

BERT Text Classification using DistilBERT and ALBERT Models
This Project Explains how to perform Text Classification using ALBERT and DistilBERT

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.

Personalized Medicine: Redefining Cancer Treatment
In this Personalized Medicine Machine Learning Project you will learn to classify genetic mutations on the basis of medical literature into 9 classes.

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.

Learn Hyperparameter Tuning for Neural Networks with PyTorch
In this Deep Learning Project, you will learn how to optimally tune the hyperparameters (learning rate, epochs, dropout, early stopping) of a neural network model in PyTorch to improve model performance.

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