sylearn
Regression models written from scratch with only NumPy. No scikit-learn inside.
syLinearRegression: ordinary least squares, solved with the pseudo-inversesyDecisionTreeRegressor: a regression tree that picks splits by mean squared errorsyRandomForestRegressor: bagging (bootstrap samples) oversyDecisionTreeRegressor
They were built to learn how these models work inside. On an air-quality (AQI) dataset they reach the same R² as scikit-learn's models with the same settings.
Install
pip install sylearn
Use
import numpy as np
from sylearn import syLinearRegression, syDecisionTreeRegressor, syRandomForestRegressor
X = np.random.rand(200, 3)
y = 4 * X[:, 0] - 2 * X[:, 1] + np.random.normal(0, 0.1, 200)
lr = syLinearRegression()
weights, intercept = lr.fit(X, y) # fit returns the learned weights and intercept
print(lr.predict(X[:5]))
tree = syDecisionTreeRegressor(max_depth=5, min_samples_split=2).fit(X, y)
print(tree.predict(X[:5]))
np.random.seed(42) # the forest uses np.random, so seed it for repeatable results
forest = syRandomForestRegressor(n_trees=10, max_depth=5).fit(X, y)
print(forest.predict(X[:5]))
X can be a NumPy array, a list of lists or a pandas DataFrame. y is a 1-D array.
Good to know
- The decision tree tries every possible split, so training gets slow on large datasets (tens of thousands of rows).
- The models do not handle missing values. Fill or drop NaN values first.
License
MIT
Metadata
Release files for sylearn 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 |
|---|---|---|---|---|
| sylearn-0.1.0.tar.gz | 3.9 kB | Without provenance | Details for sylearn-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sylearn-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for sylearn-0.1.0-py3-none-any.whl |
Total release size: 9.8 kB
Release files / sylearn-0.1.0.tar.gz
| Download URL | sylearn-0.1.0.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ade7ff9ce9dd574ce05cee774bd051545c9e100d5b9d8a1c06dfbdedaab7465a
|
|
BLAKE2b-256 checksum How to use checksums |
410aa03fa15be4c41b7ea2284751e02e499af850b1364916c9d3111d2431dff6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Release files / sylearn-0.1.0-py3-none-any.whl
| Download URL | sylearn-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b84e27bd7dd414a0ab0ce78d336a52535141d4a4b88c29258c4df794a71fb7f7
|
|
BLAKE2b-256 checksum How to use checksums |
3908c86a9f448d385c5abe8562a617caad811afd6584fb6b9ff7fdd175f09d5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Security for sylearn 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.