Home Price Prediction with Multiple Variable in 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_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: "))
age=int(input("Enter age of Home(How old is Home) : "))
print("Prediciated Price",model.predict([[sq,bdr,age]]))
print(model.intercept_)
print(model.coef_)
price=221323.0018654043 + 112.06244194*sq+23388.88007794*bdr+-3231.71790863*age

print("Formula Price",price)

 

If you are Happy with DataFlair, do not forget to make us happy with your positive feedback 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 *