Machine Learning courses with 110+ Real-time projects Start Now!!
Program 1
import pandas as pd
import numpy as np
from sklearn import linear_model
import pickle
df=pd.read_excel("D://scikit_data/emp/employee.xlsx")
print(df)
model=linear_model.LinearRegression()
model.fit(df.drop('salary',axis='columns'),df.salary)
print(model)
print("Predication with Model: ",model.predict([[7]]))
print("Coficient with Model: ",model.coef_)
print("Intercepet with Model: ",model.intercept_)
myfile1=open("pickle_model","wb")
pickle.dump(model,myfile1)
myfile1.close()
print("----------Model Dump in file--------------")
print("Load Model")
myfile2=open("pickle_model","rb")
mymodel=pickle.load(myfile2)
print(mymodel)
print("Predication with my model: ",model.predict([[7]]))
print("Coficient with my model: ",model.coef_)
print("Intercepet with my model: ",model.intercept_)
myfile2.close()