linreg-scratch
Simple linear regression (y = m*x + b) implemented from scratch with NumPy.
Install
pip install linreg-scratch
Usage
import numpy as np
from linreg_scratch import LinearRegression
x = np.array([1, 2, 3, 4, 5])
y = np.array([3, 5, 7, 9, 11])
model = LinearRegression(lr=0.01, epochs=5000) # gradient descent
model.fit(x, y)
print(model.m, model.b) # slope, intercept
print(model.predict([6, 7])) # predictions
print(model.score(x, y)) # R^2
# exact solution instead of gradient descent
LinearRegression(solver="closed").fit(x, y)
Development
pip install -e . pytest
pytest
Metadata
Release files for linreg-scratch 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| linreg_scratch-0.1.0.tar.gz | 3.9 kB | Without provenance | Details for linreg_scratch-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| linreg_scratch-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for linreg_scratch-0.1.0-py3-none-any.whl |
Total release size: 7.8 kB
Release files / linreg_scratch-0.1.0.tar.gz
| Download URL | linreg_scratch-0.1.0.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e834d87d29ebf753aec0c495622016252f95ed8f1a1813683db3b9b8821027da
|
|
BLAKE2b-256 checksum How to use checksums |
f37dc23fc396335545f5b66ecb561a144071eea734e89729ad6e261caf2e4b94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / linreg_scratch-0.1.0-py3-none-any.whl
| Download URL | linreg_scratch-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd7107373cd26e91da6c28ff0800f9aeceea9ffc8f7598dfa70de010026ebdf4
|
|
BLAKE2b-256 checksum How to use checksums |
7bf4350991723f9206c9c3be0e0bc04eacfc1d02a3d10029dfea9b603281f4c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Security for linreg-scratch 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.