Skip to content

Predicts house prices using linear regression built from scratch with NumPy and gradient descent. Great for learning core ML concepts.

Notifications You must be signed in to change notification settings

FaNa-AI/Linear-Regression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 

Repository files navigation

🏑 House Price Prediction using Gradient Descent

A simple and educational implementation of Linear Regression using Gradient Descent from scratch with NumPy to predict house prices based on cleaned housing data. Ideal for learning machine learning fundamentals without using black-box models.


πŸ“¦ Features

βœ… Load dataset from Excel
βœ… Handle missing values
βœ… Normalize features and target using StandardScaler
βœ… Train using batch gradient descent
βœ… Evaluate using Mean Squared Error (MSE)
βœ… Visualize training loss


πŸ“ Dataset

Ensure you have a file named:

Cleaned_HousePricePrediction.xlsx


With:
- A sheet named Sheet1
- A SalePrice column (target variable)
- An Id column (will be dropped)
- All other columns should be numerical features

---

## πŸš€ Getting Started

### 1️⃣ Install Dependencies

Bash

pip install pandas numpy scikit-learn matplotlib openpyxl

2️⃣ Run the Script

python your_script_name.py

---

## πŸ“Š Example Output

txt

MSE: 145237600.25

πŸ“ˆ Training loss plot (MSE per iteration):

![Gradient Descent Plot](example_plot.png)

---

## βš™οΈ Hyperparameters

You can tune the following parameters in the script:

Python

learning_rate = 0.01       # Step size for gradient descent
n_iterations = 1000        # Number of training iterations

---

## πŸ“Œ Notes

* This is a manual implementation of linear regression; no sklearn.linear_model used.
* Both features and target variable are standardized using StandardScaler.
* Ideal for educational purposes and understanding the core of gradient-based optimization.

---

## πŸ“ƒ License

MIT License Β© 2025
Feel free to use and modify it for personal or academic use.

---

## πŸ™Œ Contributions

Pull requests are welcome! If you'd like to improve performance, add visualization, or support other regression methods, feel free to contribute.

About

Predicts house prices using linear regression built from scratch with NumPy and gradient descent. Great for learning core ML concepts.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published