House Price Prediction Application in Machine Learning
Machine Learning courses with 100+ 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("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') # Data Frame with Area
mymodel.fit(mynewdf,mydf.price)
area_df=pd.read_excel("homearea.xlsx")
print(area_df)
pred=mymodel.predict((area_df))
print(pred)
area_df['Price']=pred
print(area_df)
area_df.to_excel("newprediction.xlsx")
# ar=int(input("Enter area for Price prediction"))
# print("Preditected Price is:",mymodel.predict([[ar]]))
# print("Coficient(β): ",mymodel.coef_)
# print("Intercept(α): ",mymodel.intercept_)
# # y=α+β*area
# print("Manual Price for 5000 sqft:",mymodel.intercept_ + mymodel.coef_*5000)
# print("Model is Trained now")
# print(mymodel)
#print("This is new Data Frame")
#print(mynewdf)
#print(mymodel)
Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

