Salary Prediction of Employees in Machine Learning

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

Program 1

# ML Model for Salary Predication

import pandas as pd
import numpy as np
import matplotlib.pyplot as mlt
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)
ex=float(input("Enter an Experience: "))
print("Predicated Salary: ",mymodel.predict([[ex]]))
alpha=mymodel.intercept_
beta=mymodel.coef_
print("Formula Predication: ",(alpha+beta*ex))
mydf_exp=pd.read_excel("D://MLFile/empexperience.xlsx")
print(mydf_exp)
predsal=mymodel.predict((mydf_exp))
print("-------------------------------------------------")
mydf_exp['Salary']=predsal
print(mydf_exp)
mydf_exp.to_excel("D://MLFile/newempData.xlsx")
mlt.scatter(mydf_exp.experience,mydf_exp.Salary,color="green",marker="+")
mlt.plot(mydf_exp.experience,mydf_exp.Salary,color="red")
mlt.xlabel("Years of Experience")
mlt.ylabel("Salary(In Rupees)")
mlt.show()
print("Predication Done Successfully............")

 

Did you like our efforts? 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 *