Skip to content

Linear Regression implementation from scratch using only NumPy. Features three gradient descent methods (Batch, SGD, Mini-Batch), polynomial feature engineering, L1 regularization, and early stopping. Includes comprehensive experiment logs documenting the complete journey from negative Rยฒ scores to 98%+ accuracy, 95% test coverage.

Notifications You must be signed in to change notification settings

willow788/Linear-Regression-model-from-scratch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

129 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฏ Linear Regression from Scratch

Python NumPy Pandas scikit-learn Jupyter

MIT License Code Style: Black Tests

A Journey from Negative Rยฒ to 98%+ Accuracy ๐Ÿš€


๐Ÿ“Š Quick Stats


Best Performance

Polynomial Features

Gradient Descent

Code Coverage

๐ŸŒŸ What Makes This Special?

๐ŸŽ“ Pure Implementation ๐Ÿงฎ Multiple Algorithms ๐Ÿ“ˆ Advanced Features ๐Ÿ“ Detailed Logs
Built from scratch using only NumPy Batch, SGD & Mini-Batch GD Polynomial features & L1 reg Complete failure-to-success journey

graph LR
    A[๐Ÿ“Š Load Data] --> B[๐Ÿ”ง Feature Engineering]
    B --> C[๐Ÿ“ Normalization]
    C --> D[๐ŸŽฏ Train Model]
    D --> E{Choose Method}
    E -->|Batch GD| F[๐Ÿ“Š Rยฒ:  95.84%]
    E -->|Stochastic GD| G[๐Ÿ“Š Rยฒ: 98.50%]
    E -->|Mini-Batch GD| H[๐Ÿ† Rยฒ: 98.74%]
    F --> I[๐Ÿ“ˆ Evaluate]
    G --> I
    H --> I
    I --> J[โœจ Predictions]
    
    style A fill:#e1f5ff
    style H fill:#90EE90
    style J fill:#FFD700
Loading

๐Ÿ“– Table of Contents


โœจ Features

๐ŸŽฏ Core Features

  • โœ… Pure NumPy Implementation

    • No sklearn for core algorithm
    • Deep understanding of math
    • Educational & transparent
  • โœ… Three Gradient Descent Methods

    • ๐Ÿ“Š Batch GD
    • โšก Stochastic GD
    • ๐Ÿ”„ Mini-Batch GD
  • โœ… Advanced ML Techniques

    • ๐Ÿ”ข Polynomial Features (up to degree 2)
    • ๐ŸŽš๏ธ L1 Regularization (Lasso)
    • โฑ๏ธ Early Stopping
    • ๐Ÿ“ Z-Score Normalization

๐Ÿ“Š Analysis Features

  • โœ… Robust Evaluation

    • ๐Ÿ”„ K-Fold Cross-Validation
    • ๐Ÿ“ˆ Multiple Metrics (MSE, RMSE, MAE, Rยฒ)
    • ๐Ÿ“Š Train/Test Performance
  • โœ… Rich Visualizations

    • ๐Ÿ“‰ Loss Convergence Curves
    • ๐ŸŽฏ Residual Analysis
    • ๐Ÿ”ฅ Correlation Heatmaps
    • ๐Ÿ“Š Actual vs Predicted Plots
    • ๐Ÿ† Feature Importance Charts
  • โœ… Production Ready

    • ๐Ÿงช 95%+ Test Coverage
    • ๐Ÿ“ Comprehensive Documentation
    • ๐Ÿณ Docker Support

๐Ÿš€ Quick Start

Get Up and Running in 60 Seconds! โšก

# 1๏ธโƒฃ Clone the repository
git clone https://github.com/willow788/Linear-Regression-model-from-scratch.git
cd Linear-Regression-model-from-scratch

# 2๏ธโƒฃ Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# 3๏ธโƒฃ Install dependencies
pip install -r requirements.txt

# 4๏ธโƒฃ Run the model
python main.py

# ๐ŸŽ‰ That's it! Your model is training! 
๐Ÿณ Docker Quick Start (Click to expand)
# Build the image
docker build -t linear-regression . 

# Run the container
docker run -it -p 8888:8888 linear-regression

# Or use docker-compose
docker-compose up

๐Ÿ’ก Usage Examples

๐ŸŽฏ Basic Usage

from linear_regression import LinearRegression
from data_preprocessing import load_and_preprocess_data

# Load your data
X_train, X_test, y_train, y_test = load_and_preprocess_data('Advertising.csv')

# Create and train model
model = LinearRegression(
    learn_rate=0.02,
    iter=50000,
    method='batch',
    l1_reg=0.1
)

model.fit(X_train, y_train)

# Make predictions
predictions = model.predict(X_test)

print(f"โœจ Model Rยฒ Score: {model.evaluate(y_test, predictions):.4f}")

๐Ÿ”„ Comparing Different Methods

methods = {
    '๐Ÿ“Š Batch GD':  {'method': 'batch', 'iter': 50000},
    'โšก Stochastic GD': {'method': 'stochastic', 'iter': 50},
    '๐Ÿ”„ Mini-Batch GD': {'method': 'mini-batch', 'iter': 1000, 'batch_size': 16}
}

for name, params in methods.items():
    model = LinearRegression(learn_rate=0.01, **params)
    model.fit(X_train, y_train)
    score = calculate_r2(y_test, model.predict(X_test))
    print(f"{name}: Rยฒ = {score:.4f}")

๐Ÿ“Š Cross-Validation

from model_evaluation import cross_validation_score

# Perform 5-fold cross-validation
cv_score = cross_validation_score(X, y, k=5)
print(f"๐ŸŽฏ Cross-Validated Rยฒ Score: {cv_score:.4f}")

๐Ÿ“ˆ Visualization

from visualization import (
    plot_loss_convergence,
    plot_residuals,
    plot_actual_vs_predicted
)

# Plot loss over iterations
plot_loss_convergence(model. loss_history)

# Analyze residuals
plot_residuals(y_test, predictions)

# Compare actual vs predicted
plot_actual_vs_predicted(y_test, predictions)

๐Ÿ“ Project Structure

๐Ÿ“ฆ Linear-Regression-model-from-scratch/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ Version- 1/                          # ๐Ÿ”ด Initial experiments
โ”‚   โ”œโ”€โ”€ ๐Ÿ““ experiment_log.txt               # The negative Rยฒ saga
โ”‚   โ””โ”€โ”€ ๐Ÿ“Š Raw jupyter Notebook/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ Version- 2/                          # ๐ŸŸก Feature engineering
โ”‚   โ”œโ”€โ”€ ๐Ÿ““ experiment_log.txt
โ”‚   โ””โ”€โ”€ ๐Ÿ“Š Raw jupyter Notebook/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ Version- 3/                          # ๐ŸŸ  Normalization fixes
โ”‚   โ”œโ”€โ”€ ๐Ÿ““ experiment_log.txt
โ”‚   โ””โ”€โ”€ ๐Ÿ“Š Raw jupyter Notebook/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ Version- 9/                          # ๐ŸŸข Production ready! 
โ”‚   โ”œโ”€โ”€ ๐Ÿ“Š Raw jupyter Notebook/
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ““ sales. ipynb                 # Complete analysis
โ”‚   โ””โ”€โ”€ ๐Ÿ Python Files/
โ”‚       โ”œโ”€โ”€ ๐Ÿ“„ data_preprocessing.py       # Data pipeline
โ”‚       โ”œโ”€โ”€ ๐Ÿ“„ linear_regression.py        # Core model
โ”‚       โ”œโ”€โ”€ ๐Ÿ“„ model_evaluation.py         # Metrics & CV
โ”‚       โ”œโ”€โ”€ ๐Ÿ“„ visualization. py            # Plotting utils
โ”‚       โ”œโ”€โ”€ ๐Ÿ“„ main.py                     # Main script
โ”‚       โ””โ”€โ”€ ๐Ÿ“„ config.py                   # Configuration
โ”‚
โ”œโ”€โ”€ ๐Ÿงช tests/                               # Test suite
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ test_linear_regression.py
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ test_data_preprocessing.py
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ test_model_evaluation.py
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ test_visualization.py
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ test_integration.py
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ conftest.py
โ”‚
โ”œโ”€โ”€ ๐Ÿ“Š outputs/                             # Generated visualizations
โ”‚   โ”œโ”€โ”€ ๐Ÿ–ผ๏ธ loss_convergence.png
โ”‚   โ”œโ”€โ”€ ๐Ÿ–ผ๏ธ residual_plot.png
โ”‚   โ”œโ”€โ”€ ๐Ÿ–ผ๏ธ correlation_matrix.png
โ”‚   โ”œโ”€โ”€ ๐Ÿ–ผ๏ธ actual_vs_predicted.png
โ”‚   โ””โ”€โ”€ ๐Ÿ–ผ๏ธ feature_importance.png
โ”‚
โ”œโ”€โ”€ ๐Ÿ“Š Advertising.csv                      # Dataset
โ”œโ”€โ”€ ๐Ÿ“‹ requirements.txt                     # Dependencies
โ”œโ”€โ”€ ๐Ÿ“‹ requirements-dev.txt                 # Dev dependencies
โ”œโ”€โ”€ ๐Ÿณ Dockerfile                           # Container config
โ”œโ”€โ”€ ๐Ÿณ docker-compose.yml                   # Orchestration
โ”œโ”€โ”€ โš™๏ธ Makefile                             # Utility commands
โ”œโ”€โ”€ ๐Ÿ“– README.md                            # You are here! 
โ”œโ”€โ”€ ๐Ÿ“– INSTALL.md                           # Installation guide
โ””โ”€โ”€ ๐Ÿ“œ LICENSE                              # MIT License

๐Ÿงช The Journey

From Failure to Success: A Data Science Story ๐Ÿ“š

Version Rยฒ Score Key Learnings

๐Ÿ”ด Version 1 The Crisis

-18. 77 ๐Ÿ˜ฑ

Problems Discovered:

  • โŒ No feature normalization
  • โŒ Learning rate too high
  • โŒ Linear features insufficient

Breakthrough: "Failure teaches more than success ever could"

๐ŸŸก Version 2 Engineering

~0.60 ๐Ÿ“ˆ

Improvements Made:

  • โœ… Added polynomial features
  • โœ… Implemented basic normalization
  • โš ๏ธ Still unstable convergence

๐ŸŸ  Version 3 Refinement

~0.85 ๐Ÿ“Š

Progress:

  • โœ… Z-score normalization
  • โœ… Tuned learning rates
  • โœ… Added interaction terms
  • โš ๏ธ Slight overfitting detected

๐ŸŸข Version 9 Production

0.9874 ๐Ÿ†

Final Optimizations:

  • โœ… L1 regularization (ฮป = 0.15)
  • โœ… Early stopping (patience = 1000)
  • โœ… K-fold cross-validation
  • โœ… Multiple GD methods
  • โœ… Comprehensive testing

๐Ÿ“ˆ Progress Visualization

Rยฒ Score Evolution
โ”‚
1.0 โ”ค                                                    โ–ˆโ–ˆโ–ˆโ–ˆ ๐Ÿ†
0.9 โ”ค                                           โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
0.8 โ”ค                                  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
0.7 โ”ค                         โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
0.6 โ”ค                โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
0.5 โ”ค       โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
0.0 โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ
   -1. 0โ”คโ–ˆโ–ˆโ–ˆ                                              Iterations
-10.0 โ”คโ–ˆโ–ˆโ–ˆ ๐Ÿ˜ฑ
-18.0 โ”คโ–ˆโ–ˆโ–ˆ
      V1   V2      V3           V4-V8              V9

๐Ÿ“Š Performance Metrics

๐Ÿ† Model Comparison

Method Test Rยฒ Train Rยฒ RMSE MAE Training Time
๐Ÿ“Š Batch GD 0.9584 0.9509 0.2249 0.1533 ~45s
โšก Stochastic GD 0.9850 0.9848 0.1352 0.1118 ~5s
๐Ÿ”„ Mini-Batch GD 0.9874 ๐Ÿ† 0.9860 0.1238 0.1011 ~12s

๐Ÿ“ˆ Cross-Validation Results (5-Fold)

| Fold | Rยฒ Score | Status | |: ----:|:--------:|:------:| | 1 | 0.9870 | โœ… | | 2 | 0.9860 | โœ… | | 3 | 0.9925 | โœ… ๐Ÿ† | | 4 | 0.9867 | โœ… | | 5 | 0.9690 | โœ… | | Mean | 0.9842 | โœจ |


๐Ÿ”ฌ Mathematical Foundation

The Math Behind the Magic โœจ

๐Ÿ“ Linear Regression Equation

$$\hat{y} = X\mathbf{w} + b$$

Where:

  • $\hat{y}$ = predictions
  • $X$ = feature matrix
  • $\mathbf{w}$ = weights
  • $b$ = bias

๐ŸŽฏ Loss Function (with L1 Regularization)

$$L(\mathbf{w}, b) = \frac{1}{2m}\sum_{i=1}^{m}(h_\mathbf{w}(x^{(i)}) - y^{(i)})^2 + \frac{\lambda}{2}\sum_{j=1}^{n}|w_j|$$

Where:

  • $m$ = number of samples
  • $\lambda$ = regularization parameter
๐Ÿ“Š Gradient Descent Update Rules (Click to expand)

Weight Update: $$\mathbf{w} := \mathbf{w} - \alpha \cdot \frac{1}{m}X^T(X\mathbf{w} - \mathbf{y}) - \alpha \cdot \lambda \cdot \text{sign}(\mathbf{w})$$

Bias Update: $$b := b - \alpha \cdot \frac{1}{m}\sum_{i=1}^{m}(h_\mathbf{w}(x^{(i)}) - y^{(i)})$$

Parameters:

  • $\alpha$ = learning rate
  • $\lambda$ = L1 regularization parameter
  • $\text{sign}(\mathbf{w})$ = sign function for L1 penalty
๐Ÿ”ข Polynomial Feature Expansion (Click to expand)

Original Features: $[TV, Radio, Newspaper]$

Expanded to 9 features:

Feature # Expression Description
1 $TV$ Original TV budget
2 $Radio$ Original Radio budget
3 $Newspaper$ Original Newspaper budget
4 $TV^2$ Quadratic TV effect
5 $Radio^2$ Quadratic Radio effect
6 $Newspaper^2$ Quadratic Newspaper effect
7 $TV \times Radio$ Interaction effect
8 $TV \times Newspaper$ Interaction effect
9 $Radio \times Newspaper$ Interaction effect

๐Ÿ“ˆ Visualizations

๐Ÿ“Š Model Performance Insights

๐Ÿ“‰ Loss Convergence

Loss Convergence

Smooth convergence to global minimum

๐ŸŽฏ Residual Analysis

Residual Plot

Random scatter indicates good fit

๐Ÿ“Š Actual vs Predicted

Actual vs Predicted

Points close to diagonal line

๐Ÿ”ฅ Correlation Matrix

Correlation Heatmap

Feature relationships visualized

๐Ÿ† Feature Importance

Feature Importance

TV advertising shows strongest impact on sales


๐Ÿงฐ Tech Stack

Built With Modern Tools ๐Ÿ› ๏ธ


Python 3.8+
Core Language

NumPy
Numerical Computing

Pandas
Data Manipulation

Scikit-Learn
Validation Tools

Jupyter
Interactive Analysis

Matplotlib
Visualizations

Seaborn
Statistical Plots

Docker
Containerization

๐Ÿ“Š Dataset

๐Ÿ“ˆ Advertising Dataset

Attribute Details
๐Ÿ“ Source Kaggle / UCI ML Repository
๐Ÿ“Š Samples 200 observations
๐Ÿ”ข Features TV, Radio, Newspaper (advertising budgets in $1000s)
๐ŸŽฏ Target Sales (in $1000s of units)
โœ… Quality No missing values
๐Ÿ“ˆ Correlation TV (0.78), Radio (0.58), Newspaper (0.23) with Sales
๐Ÿ“Š Sample Data Preview (Click to expand)
   TV    Radio  Newspaper  Sales
0  230. 1  37.8   69.2      22.1
1  44.5   39.3   45.1      10.4
2  17.2   45.9   69.3      9.3
3  151.5  41.3   58.5      18.5
4  180.8  10.8   58.4      12.9

๐ŸŽ“ Key Learnings

๐Ÿ’ก Insights from Building ML from Scratch

๐Ÿ”‘ Technical Insights

  1. Normalization is Critical ๐ŸŽฏ

    • Without it, gradients explode
    • Z-score normalization works best
    • Apply to both features AND targets
  2. Feature Engineering Matters ๐Ÿ”ง

    • Polynomial terms capture non-linearity
    • Interaction terms reveal relationships
    • Domain knowledge helps feature selection
  3. Regularization Prevents Overfitting ๐Ÿ›ก๏ธ

    • L1 (Lasso) performs feature selection
    • Sparsity helps interpretability
    • Balance between bias and variance

๐Ÿ“š Development Insights

  1. Hyperparameter Tuning is an Art ๐ŸŽจ

    • Learning rate: too high = divergence
    • Too low = slow convergence
    • Cross-validation finds sweet spot
  2. Different Methods, Different Trade-offs โš–๏ธ

    • Batch GD: Stable but slow
    • SGD: Fast but noisy
    • Mini-Batch: Best of both worlds
  3. Document Your Failures ๐Ÿ“

    • Negative Rยฒ taught more than success
    • Experiment logs are invaluable
    • Share your learning journey

๐Ÿš€ Future Roadmap

What's Next? ๐Ÿ”ฎ

  • ๐Ÿ”„ L2 Regularization (Ridge)

    • Compare with L1
    • Implement Elastic Net (L1 + L2)
  • ๐ŸŽฏ Adaptive Learning Rates

    • Adam optimizer
    • RMSprop
    • Learning rate scheduling
  • ๐Ÿ” Automated Hyperparameter Tuning

    • Grid Search
    • Random Search
    • Bayesian Optimization
  • ๐Ÿ“Š Extended Dataset Support

    • Boston Housing
    • California Housing
    • Custom datasets
  • ๐ŸŒ Web Interface

    • Interactive predictions
    • Real-time visualization
    • Model playground
  • ๐Ÿ“ฑ API Development

    • REST API with FastAPI
    • Model serving
    • Deployment pipeline
  • ๐Ÿ“š Educational Content

    • Step-by-step tutorials
    • Video explanations
    • Blog posts

๐Ÿ’ป Command Reference

โšก Quick Commands

# ๐Ÿ“ฆ Installation
make install              # Install production dependencies
make install-dev          # Install dev dependencies

# ๐Ÿงช Testing
make test                 # Run all tests
make test-cov             # Run tests with coverage report

# ๐ŸŽจ Code Quality
make lint                 # Run linters
make format               # Format code with black

# ๐Ÿš€ Running
make run                  # Run main script
make jupyter              # Start Jupyter notebook

# ๐Ÿณ Docker
make docker-build         # Build Docker image
make docker-run           # Run Docker container

# ๐Ÿงน Cleanup
make clean                # Remove generated files

๐Ÿค Contributing

Join the Journey! ๐ŸŒŸ

We welcome contributions from the community!

๐Ÿ› Bug Reports

Found a bug?
Open an Issue

๐Ÿ’ก Feature Requests

Have an idea?
Suggest a Feature

๐Ÿ”ง Pull Requests

Want to contribute?
Submit a PR

๐Ÿ“‹ Contribution Steps

# 1. Fork the repository
# 2. Clone your fork
git clone https://github.com/YOUR_USERNAME/Linear-Regression-model-from-scratch.git

# 3. Create a feature branch
git checkout -b feature/AmazingFeature

# 4. Make your changes and commit
git commit -m 'โœจ Add some AmazingFeature'

# 5. Push to your branch
git push origin feature/AmazingFeature

# 6. Open a Pull Request

Please ensure:

  • โœ… Code passes all tests (pytest)
  • โœ… Code is formatted (make format)
  • โœ… Documentation is updated
  • โœ… Commit messages are descriptive

๐Ÿ“œ License

This project is licensed under the MIT License

License:  MIT

See LICENSE for more information.


๐Ÿ™ Acknowledgments

Special Thanks โค๏ธ

๐Ÿ“Š Dataset
Advertising Dataset
Kaggle Community

๐ŸŽ“ Inspiration
Andrew Ng
Machine Learning Course

๐Ÿ› ๏ธ Tools
NumPy, Pandas
Scikit-Learn Team

๐Ÿ“š Community
Stack Overflow
GitHub Community


๐Ÿ“ž Contact & Connect

Let's Connect! ๐ŸŒ

GitHub LinkedIn Email Twitter


๐Ÿ“Š Repository Stats

Stars Forks Issues License Last Commit

Language Composition

Jupyter Python

โญ Star This Repository!

If you found this project helpful, please consider giving it a star! โญ


 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—     โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—
 โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ•šโ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—    โ•šโ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•
 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—   โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•       โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—
 โ•šโ•โ•โ•โ•โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—       โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ•šโ•โ•โ•โ•โ–ˆโ–ˆโ•‘
 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘       โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘
 โ•šโ•โ•โ•โ•โ•โ•โ•   โ•šโ•โ•   โ•šโ•โ•  โ•šโ•โ•โ•šโ•โ•  โ•šโ•โ•       โ•šโ•โ•   โ•šโ•โ•  โ•šโ•โ•โ•šโ•โ•โ•šโ•โ•โ•โ•โ•โ•โ•

๐Ÿ’™ Built with passion and โ˜• by willow788

Learning by doing, one gradient descent at a time ๐Ÿš€



โฌ† Back to Top

About

Linear Regression implementation from scratch using only NumPy. Features three gradient descent methods (Batch, SGD, Mini-Batch), polynomial feature engineering, L1 regularization, and early stopping. Includes comprehensive experiment logs documenting the complete journey from negative Rยฒ scores to 98%+ accuracy, 95% test coverage.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors