📘 Lesson  ·  Lesson 92

House Price Prediction

About this Project

💡 At a Glance

A classic beginner ML project: predict a house price from its size using Linear Regression.

The Program

Python
from sklearn.linear_model import LinearRegression
import numpy as np

# size (sq ft) -> price
X = np.array([[500],[1000],[1500],[2000]])
y = np.array([150000, 250000, 350000, 450000])

model = LinearRegression()
model.fit(X, y)

pred = model.predict([[1200]])
print("Predicted price:", int(pred[0]))
Predicted price: 290000

How it Works

  • We train the model on size→price pairs.
  • fit() learns the relationship; predict() estimates a new price.

Summary

  • Linear Regression learns a straight-line relationship between input and output.
  • Use fit() to train and predict() to estimate new values.
← Back to Python Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 Live Code Editor

This page's programs are ready here — run them, edit them, and learn. No installation needed.
Powered by OneCompiler. The code loads into the editor automatically — press Run to see the output. If the editor does not open, open it in a new tab.