Skip to main content

Educational regression models built from scratch in Python

Project description

LinearRegression From Scratch

A minimal, easy-to-understand implementation of Linear Regression in Python using only NumPy.
Designed for educational purposes to show how gradient descent optimizes linear models step by step.

🚀 Features

  • Fits simple linear models with gradient descent
  • Clean OOP class structure
  • Pure NumPy implementation (no scikit-learn)
  • Supports multi-feature data
  • Easy to extend for regularization
  • Printed training loss progress
  • Simple fit, predict, and evaluate interface

📦 How to wrok?

from predictive_models import LinearRegression

toy dataset

X_train = np.array([[1], [2], [3], [4], [5]]) y_train = np.array([2, 4, 6, 8, 10])

initialize model

model = LinearRegression(learning_rate=0.01, epochs=1000)

train

model.fit(X_train, y_train)

predict

predictions = model.predict(X_train)

evaluate

mse, r2 = model.evaluate(X_train, y_train)

print("Predictions:", predictions) print(f"MSE: {mse:.4f}, R2: {r2:.4f}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

MLPredictiveModels-0.5-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file MLPredictiveModels-0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for MLPredictiveModels-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3bde435d4fae91284ae8c6b3af6097ec46f4d067b560c1714637ea50403eeba8
MD5 94acc7747aaa670eae7821af55f84f7b
BLAKE2b-256 509854b9c7071bdb9bdeefee73b50b6768f4623d718eec5d695a37a62b3a4571

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page