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