Visualization of Predicted Value using Machine Learning

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

Program 1

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn import linear_model
mydf=pd.read_excel("D://MLFile/employee.xlsx")
print(mydf)
mymodel=linear_model.LinearRegression()
mymodel.fit(mydf.drop('salary',axis='columns'),mydf.salary)
#print((mymodel))
#print(mymodel.predict([[7.5]]))
new_df=pd.read_excel("D://MLFile/empexp.xlsx")
sal=mymodel.predict((new_df))
new_df['salary']=sal
print(new_df)
new_df.to_excel("D://MLFile/employeenew.xlsx")
plt.scatter(new_df.experience,new_df.salary,color="green",marker='+')
plt.plot(new_df.experience,new_df.salary,color="blue")
plt.xlabel("Experience")
plt.ylabel("Salary(in Rs)")
plt.show()

 

Did you like this article? If Yes, please give DataFlair 5 Stars 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 *