Skip to content

myounes21/linear-regression-from-scratch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 Linear Regression from Scratch

πŸ“ Project Structure

LinearRegressionProject/
β”œβ”€β”€ data/                        # Store dataset files here
β”‚
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ linear_regression.py     # OLS, Batch GD, SGD, Mini-Batch GD
β”‚   β”œβ”€β”€ regularization.py        # Ridge (L2), Lasso (L1)
β”‚   β”œβ”€β”€ scaling.py               # Standardization, Normalization
β”‚   └── encoding.py              # One-Hot and Label Encoding
β”‚
β”œβ”€β”€ metrics/
β”‚   └── evaluation.py            # Evaluation metrics: RΒ², MSE
β”‚
β”œβ”€β”€ notebook/
β”‚   └── LinearRegressionDemo.ipynb  # Jupyter Notebook for step-by-step usage
β”‚
β”œβ”€β”€ main.py                      # Script to train/test model and run pipeline
β”œβ”€β”€ README.md                    # Project overview, instructions, and structure

This project is a complete implementation of Linear Regression from scratch using NumPy, designed to be clean, modular, and educational. It covers everything from preprocessing and encoding to regularization and different gradient descent techniques β€” all without using any machine learning libraries like scikit-learn for the model itself.


πŸš€ Features

  • πŸ“ˆ Optimization Methods

    • OLS (Ordinary Least Squares)
    • Batch Gradient Descent
    • Stochastic Gradient Descent
    • Mini-batch Gradient Descent
  • 🧩 Regularization

    • L1 Regularization (Lasso)
    • L2 Regularization (Ridge)
  • πŸ”§ Preprocessing

    • Standardization
    • Normalization
  • πŸŽ›οΈ Encoding

    • One-Hot Encoding
    • Label Encoding
  • πŸ“ Evaluation Metrics

    • RΒ² Score
    • Mean Squared Error (MSE)

🧠 Why This Project?

This project is built for learning and experimentation. Instead of relying on external ML libraries, every step β€” from optimization to regularization β€” is written from scratch using only NumPy. It’s a great resource if you're learning:

  • The math behind regression
  • How regularization affects optimization
  • How preprocessing affects learning
  • How to structure ML code modularly

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published