Vecstack
Python package for stacking (machine learning technique)
Install / Use
/learn @vecxoz/VecstackREADME
vecstack
Python package for stacking (stacked generalization) featuring lightweight functional API and fully compatible scikit-learn API
Convenient way to automate OOF computation, prediction and bagging using any number of models
- Functional API:
- Minimalistic. Get your stacked features in a single line
- RAM-friendly. The lowest possible memory consumption
- Kaggle-ready. Stacked features and hyperparameters from each run can be automatically saved in files. No more mess at the end of the competition. Log example
- Scikit-learn API:
- Standardized. Fully scikit-learn compatible transformer class exposing
fitandtransformmethods - Pipeline-certified. Implement and deploy multilevel stacking like it's no big deal using
sklearn.pipeline.Pipeline - And of course
FeatureUnionis also invited to the party
- Standardized. Fully scikit-learn compatible transformer class exposing
- Overall specs:
- Use any sklearn-like estimators
- Perform classification and regression tasks
- Predict class labels or probabilities in classification task
- Apply any user-defined metric
- Apply any user-defined transformations for target and prediction
- Python 3.9+, unofficial support for Python 2.7 and 3.4
- Win, Linux, Mac
- MIT license
- Depends on numpy, scipy, scikit-learn>=1.6.0
Get started
- FAQ
- Installation guide
- Usage:
- Tutorials:
- Examples (all examples are valid for both API with little difference in parameters):
- Functional API:
- Scikit-learn API:
- Documentation:
- Functional API or type
>>> help(stacking) - Scikit-learn API or type
>>> help(StackingTransformer)
- Functional API or type
Installation
Note: Python 3.9+ is officially supported and tested. If you’re still using Python 2.7 or 3.4 see installation details here
- Classic 1st time installation (recommended):
pip install vecstack
- Install for current user only (if you have some troubles with write permission):
pip install --user vecstack
- If your PATH doesn't work:
/usr/bin/python -m pip install vecstackC:/Python3/python -m pip install vecstack
- Upgrade vecstack and all dependencies:
pip install --upgrade vecstack
- Upgrade vecstack WITHOUT upgrading dependencies:
pip install --upgrade --no-deps vecstack
- Upgrade directly from GitHub WITHOUT upgrading dependencies:
pip install --upgrade --no-deps https://github.com/vecxoz/vecstack/archive/master.zip
- Uninstall
pip uninstall vecstack
Usage. Functional API
from vecstack import stacking
# Get your data
# Initialize 1st level estimators
models = [LinearRegression(),
Ridge(random_state=0)]
# Get your stacked features in a single line
S_train, S_test = stacking(models, X_train, y_train, X_test, regression=True, verbose=2)
# Use 2nd level estimator with stacked features
Usage. Scikit-learn API
from vecstack import StackingTransformer
# Get your data
# Initialize 1st level estimators
estimators = [('lr', LinearRegression()),
('ridge', Ridge(random_state=0))]
# Initialize StackingTransformer
stack = StackingTransformer(estimators, regression=True, verbose=2)
# Fit
stack = stack.fit(X_train, y_train)
# Get your stacked features
S_train = stack.transform(X_train)
S_test = stack.transform(X_test)
# Use 2nd level estimator with stacked features
Stacking FAQ
- How can I report an issue? How can I ask a question about stacking or vecstack package?
- How can I say thanks?
- How to cite vecstack?
- What is stacking?
- What about stacking name?
- Do I need stacking at all?
- Can you explain stacking (stacked generalization) in 10 lines of code?
- Why do I need complicated inner procedure for stacking?
- I want to implement stacking (stacked generalization) from scratch. Can you help me?
- What is OOF?
- What are estimator, learner, model?
- What is blending? How is it related to stacking?
- How to optimize weights for weighted average?
- What is better: weighted average for current level or additional level?
- What is bagging? How is it related to stacking?
- How many models should I use on a given stacking level?
- How many stacking levels should I use?
- How do I choose models for stacking?
- I am trying hard but still can't beat my best single model with stacking. What is wrong?
- What should I choose: functional API (
stackingfunction) or Scikit-learn API (StackingTransformer)? - How do parameters of
stackingfunction andStackingTransformercorrespond? - Why Scikit-learn API was implemented as transformer and not predictor?
- How to estimate stacking training time and number of models which will be built?
- Which stacking variant should I use: 'A' ('oof_pred_bag') or 'B' ('oof_pred')?
- How to choose number of folds?
- [When I transform train set I see 'Train set w
Related Skills
YC-Killer
2.7kA library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star ⭐️ this repository and use the link in the readme to join our open source AI research team.
flutter-tutor
Flutter Learning Tutor Guide You are a friendly computer science tutor specializing in Flutter development. Your role is to guide the student through learning Flutter step by step, not to provide d
groundhog
398Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).
last30days-skill
16.9kAI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
