House price prediction is one of the most common regression problems in Machine Learning. In this project, we use the Linear Regression algorithm to learn the relationship between house area and price.
The model is trained using historical data and can predict the estimated price for a new house.
This project teaches:
1. Install libraries :
pip install pandas numpy matplotlib scikit-learn
2. Create Dataset
import pandas as pd
data = {
"Area":[1000,1200,1500,1800,2000,2500],
"Price":[20,25,30,36,40,50]
}
df=pd.DataFrame(data)
print(df)
3. Train Model
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
X=df[['Area']]
y=df['Price']
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.2,random_state=42)
model=LinearRegression()
model.fit(X_train,y_train)
4.Prediction
prediction=model.predict([[1700]])
print("Predicted Price:",prediction[0],"Lakhs")
5. Accuracy
from sklearn.metrics import r2_score
pred=model.predict(X_test)
print("R2 Score:",r2_score(y_test,pred))
Get an official Project Completion Certificate with a unique ID & QR verification — perfect for internships, resumes, and college submissions.
Get Certificate →