Skip to content

A comparison of Linear Regression implemented from scratch using Gradient Descent in Python versus Scikit-learn’s built-in LinearRegression model. Includes training, evaluation using Mean Squared Error, and insights into how gradient descent compares with the closed-form solution.

Notifications You must be signed in to change notification settings

Chetanpyasi/linear-regression-scratch-vs-sklearn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Linear Regression from Scratch vs Scikit-learn

This project implements Linear Regression using Gradient Descent from scratch in Python and compares its performance with the built-in LinearRegression model from scikit-learn.

📌 Features

  • Custom Linear Regression implementation using NumPy
  • Comparison with Scikit-learn's implementation
  • Evaluation using Mean Squared Error (MSE)

🚀 Installation

Clone the repository and install dependencies:

pip install -r requirements.txt

📂 Requirements

  • numpy
  • scikit-learn

🧑‍💻 Usage

Run the script:

python main.py

You will see output like:

Custom Model Mean Squared Error: 0.0803
Sklearn Model Mean Squared Error: 0.0797

✅ Comparison

  • Custom Model: Uses manual gradient descent with adjustable learning rate and iterations.
  • Scikit-learn Model: Uses closed-form solution (Normal Equation).

Both should perform similarly on this dataset, with minor differences due to noise and optimization steps.


✨ Built for learning purposes to understand the inner workings of Linear Regression. "# linear-regression-scratch-vs-sklearn"

About

A comparison of Linear Regression implemented from scratch using Gradient Descent in Python versus Scikit-learn’s built-in LinearRegression model. Includes training, evaluation using Mean Squared Error, and insights into how gradient descent compares with the closed-form solution.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published