Skip to main content

A library for Augmented Model Stacking and ensemble with a focus on flexibility and performance.

Project description

LayerLearn — Flexible Model Library

layerlearn is a small Python package that makes it easy to build stacked estimators (regressors and classifiers) around scikit-learn models.

Requirements

  • Python 3.8+
  • scikit-learn
  • numpy

Installation

From PyPI:

pip install layerlearnyashw

From source (recommended for development):

git clone https://github.com/Mr-J12/newalgo.git
cd newalgo
pip install -e .

Examples & tests

See example scripts in the repository:

  • testing/regression_default_dataset.py
  • testing/classification_default_dataset.py
  • testing/instantiation_checking.py

Quick examples

Regression:

from layerlearn.flexiblestacked import FlexibleStackedRegressor
from sklearn.linear_model import LinearRegression
from sklearn.ensemble import RandomForestRegressor
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split

X, y = make_regression(n_samples=200, n_features=10, noise=10)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)

base = LinearRegression()
meta = RandomForestRegressor(random_state=0)
stack = FlexibleStackedRegressor(base, meta)
stack.fit(X_train, y_train)
preds = stack.predict(X_test)
print(preds[:5])

Classification:

from layerlearn.flexiblestacked import FlexibleStackedClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split

X, y = make_classification(n_samples=200, n_features=10, n_classes=2, random_state=0)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)

base = LogisticRegression(max_iter=1000)
meta = RandomForestClassifier(random_state=0)
stack = FlexibleStackedClassifier(base, meta)
stack.fit(X_train, y_train)
preds = stack.predict(X_test)
print(preds[:5])

Visualization

Regression Default Dataset Report

Classification Default Dataset Report

Development

  • Install development requirements (scikit-learn, numpy).
  • Run example scripts to verify behavior: python testing/regression_default_dataset.py

License

See LICENSE for details.

Project details


Download files

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

Source Distribution

layeredlearning-1.2.0.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

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

layeredlearning-1.2.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file layeredlearning-1.2.0.tar.gz.

File metadata

  • Download URL: layeredlearning-1.2.0.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for layeredlearning-1.2.0.tar.gz
Algorithm Hash digest
SHA256 3259d659cee9c0c8d8e8b5e2007964d260d48f00552732dc56c881653f8063d3
MD5 bb7b7875f5a7221d4d3b9f97b1657aa8
BLAKE2b-256 ab16553e251381a6dc5d9e754545ee4fbcfa3902450fc183249625a431d41aec

See more details on using hashes here.

File details

Details for the file layeredlearning-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for layeredlearning-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01781bf49b01c5e461ed19a3472b6d7d2ec3c6564952e8832cd18726718f702e
MD5 ac0c8acbcbeb65df19d1a83bee3b5d20
BLAKE2b-256 79b339fa254f0a7e58883161e9a495fbdddd641a28810e93aafbbd0973cbd6f1

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