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. this library is designed to provide a flexible and easy-to-use interface for building stacked models, allowing users to combine multiple models to improve performance. with this library you can stack any scikit-learn compatible models and also you can use the default models provided by the library.
Features
- Flexible Stacking: Easily stack any scikit-learn compatible models.
- Regression and Classification: Supports both regression and classification tasks.
- Customizable: Allows customization of the base and meta models.
- Easy to Use: Simple API for building and training stacked models.
Requirements
- Python 3.8+
- scikit-learn
- numpy
- xgboost
- catboost
- lightgbm
Installation
From PyPI:
pip install layeredlearning
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file layeredlearning-1.5.2.tar.gz.
File metadata
- Download URL: layeredlearning-1.5.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f90abccbcd949f347d04d0d915bc8a7412b53ad8cc4f1f576e2b5d70d5d07ad3
|
|
| MD5 |
9b0e83ee6e5ca6be994c39a355d156aa
|
|
| BLAKE2b-256 |
be9cddea3d721738090bcab552c93fe55dd9b6a4f34ad50aa5ada8a6d27b40a5
|
File details
Details for the file layeredlearning-1.5.2-py3-none-any.whl.
File metadata
- Download URL: layeredlearning-1.5.2-py3-none-any.whl
- Upload date:
- Size: 23.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5ba6e6345154bb77bd895988dcde169df21327389f255b88c4838cec043bd92
|
|
| MD5 |
eb4fd1b0fdc3db7dfcf11326a7cd792a
|
|
| BLAKE2b-256 |
5916ea092475caf0721afab6228e59bc1a611318eeedb1ef5f9067e5333e8dfe
|