A Machine Learning project that predicts house prices based on size, bedrooms and location — built with Python, Scikit-Learn and Matplotlib.
This is my first end-to-end Machine Learning project. I built a model that can predict the selling price of a house when given three inputs — the size of the house, the number of bedrooms, and the location quality score.
I built this project to apply what I learned from the Machine Learning Specialization taught by Andrew Ng on Coursera.
Given:
→ Size of house (sqft)
→ Number of bedrooms
→ Location score (1 to 10)
Predict:
→ Estimated price of the house (USD)
I created a realistic dataset of 20 houses. No external dataset was used.
| Feature | Type | Description |
|---|---|---|
size_sqft |
int | Size of house in square feet |
bedrooms |
int | Number of bedrooms |
location_score |
int | Location quality from 1 (poor) to 10 (excellent) |
price_usd |
float | House price in USD — this is what we predict |
1. Create Dataset
↓
2. Explore and Understand Data
↓
3. Visualize with Charts
↓
4. Split into Train and Test sets (80/20)
↓
5. Train Linear Regression Model
↓
6. Evaluate Performance (R² Score, MSE)
↓
7. Predict New House Prices
| Metric | Result |
|---|---|
| Algorithm | Linear Regression |
| R² Score | ~0.99 |
| Train set | 80% of data |
| Test set | 20% of data |
R² Score of 0.99 means the model explains 99% of the price variation — very high accuracy for this dataset.
- 📉 House Size vs Price — scatter plot
- 🛏️ Bedrooms vs Price — scatter plot
- 🎯 Actual Price vs Predicted Price — comparison chart
predict_price(size=1500, bedrooms=3, location_score=7)
# ╔══════════════════════════════╗
# ║ House Price Prediction ║
# ║ Size : 1500 sqft ║
# ║ Bedrooms : 3 ║
# ║ Location Score: 7/10 ║
# ║ Predicted Price: $96,500 ║
# ╚══════════════════════════════╝| Tool | Version | Purpose |
|---|---|---|
| Python | 3.x | Programming language |
| NumPy | Latest | Numerical computation |
| Pandas | Latest | Data handling |
| Matplotlib | Latest | Charts and visualization |
| Scikit-Learn | Latest | ML model |
| Jupyter Notebook | Latest | Development environment |
On Google Colab — no installation needed
- Open the
.ipynbfile in this repository - Click Open in Colab
- Click Runtime → Run all
On your local machine
pip install numpy pandas matplotlib scikit-learn jupyter
jupyter notebook House_Price_Prediction.ipynbHouse-Price-Prediction/
├── House_Price_Prediction.ipynb # main notebook
└── README.md # project documentation
- Use a real dataset from Kaggle with 1000+ houses
- Add more features — house age, garage, garden, floors
- Compare with Random Forest and XGBoost models
- Build a simple web interface using Flask
- Deploy the model online using Streamlit
Before this project, I only knew the theory of Linear Regression. Building it end-to-end taught me how to prepare real data, train a model, measure its accuracy, and make actual predictions. It also taught me how important data visualization is — the charts made it easy to understand what the model was learning.
This project gave me the confidence to take on more complex ML problems.
- 📂 ML-Practice Repository — all my ML learning and practice notebooks
- 📂 Python-Documentation — my complete 30-class Python training course
🎓 Rayhan Uddin · Computer Science Student · Bangladesh
"Every expert was once a beginner. This project is one step in my journey."