Machine Learning Tutorials

Home Price Prediction with Multiple Variable in Machine Learning 0

Home Price Prediction with Multiple Variable in Machine Learning

Program 1 import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model mydf=pd.read_csv(“D://scikit_data/home/homeprices.csv”) mydf.bedrooms=mydf.bedrooms.fillna(mydf.bedrooms.median()) print(mydf) model=linear_model.LinearRegression() # print(model) model.fit(mydf.drop(‘price’,axis=’columns’),mydf.price) print(model) sq=int(input(“Enter area: “)) bdr=int(input(“Enter No of Bedrooms: “))...

Salary Prediction Model using Machine Learning 0

Salary Prediction Model using Machine Learning

Program 1 import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model df=pd.read_excel(“D://scikit_data/newemp/employee.xlsx”) df=df.rename(columns={‘test_score(out of 10)’:’TestScore’}) df=df.rename(columns={‘interview_score(out of 10)’:’InteviewScore’}) df=df.rename(columns={‘salary($)’:’Salary’}) my_dict={‘zero’:0,’one’:1,’two’:2,’three’:3,’four’:4,’five’:5,’six’:6,’seven’:7,’eight’:8,’nine’:9,’ten’:10} df[‘experience’]=df[‘experience’].map(my_dict) df.experience=df.experience.fillna(2) df.TestScore=df.TestScore.fillna(df.TestScore.median()) # print(df) model=linear_model.LinearRegression() model.fit(df.drop(‘Salary’,axis=’columns’),df.Salary)...

Insurance Price Prediction using Machine Learning 0

Insurance Price Prediction using Machine Learning

Program 1 import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model from sklearn.model_selection import train_test_split from sklearn.metrics import r2_score df=pd.read_csv(“D://scikit_data/insurancedata/insurance.csv”) map_dict={‘female’:0,’male’:1} df[‘sex’]=df[‘sex’].map(map_dict) map_dict={‘southwest’:0,’southeast’:1,’northwest’:2,’northeast’:3} df[‘region’]=df[‘region’].map(map_dict) map_dict={‘yes’:1,’no’:0} df[‘smoker’]=df[‘smoker’].map(map_dict) #...

Visualization of Predicted Value using Machine Learning 0

Visualization of Predicted Value using Machine Learning

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)”)...

Marks Prediction of Students in Machine Learning 0

Marks Prediction of Students in Machine Learning

Program 1 # Machine Learning model for student marks predication import pandas as pd import numpy as np import matplotlib.pyplot as plt import os from sklearn import linear_model mydf=pd.read_excel(“D://MLFile/result.xlsx”) mymodel=linear_model.LinearRegression() mymodel.fit(mydf.drop(‘marks’,axis=’columns’),mydf.marks) # Trained Data...

Salary Prediction of Employees in Machine Learning 0

Salary Prediction of Employees in Machine Learning

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:...

Home Price Prediction Application in Machine Learning 0

Home Price Prediction Application in Machine Learning

Program 1 import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model mydf=pd.read_excel(“homeprice.xlsx”) # Data Frame with Area and Price print(mydf) plt.xlabel(‘Area’) plt.ylabel(‘Price’) plt.scatter(mydf.area,mydf.price,color=’blue’,marker=’*’) plt.show() mymodel=linear_model.LinearRegression() mynewdf=mydf.drop(‘price’,axis=’columns’) #...