House Price Prediction Application in Machine Learning

Machine Learning courses with 100+ Real-time projects Start Now!!

Program 1

Machine Learning Dataset

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

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 *