How to Save Trained Model using Joblib in Machine Learning

Free Machine Learning courses with 130+ real-time projects Start Now!!

Program 1

import pandas as pd        # Version  2.2.2
import numpy as np         # Version 1.24.3
import matplotlib.pyplot as plt # Version 3.7.1
from sklearn import  linear_model # 1.5.1
import joblib
df=pd.read_csv("D://scikit_data/home/homeprices.csv")
print(df)
model=linear_model.LinearRegression()
model.fit(df.drop('price',axis='columns'),df.price)
print(model)
print("Model Predication: ",model.predict([[3400]]))
print("Model Coficient: ",model.coef_)
print("Model Intercept: ",model.intercept_)
joblib.dump(model,'model_joblib')
print("--------------File Dump-------------")
mymodel=joblib.load('model_joblib')
print(mymodel)
print("My Model Predication: ",mymodel.predict([[3400]]))
print("My Model Coficient: ",mymodel.coef_)
print("My Model Intercept: ",mymodel.intercept_)

 

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *