Skip to main content

DeepStack: Ensembles for Deep Learning

Project description


DeepStack: Ensembles for Deep Learning

Travis PyPI version Download Stats

DeepStack is a Python module for building Deep Learning Ensembles originally built on top of Keras and distributed under the MIT license.


pip install deepstack


Stacking is based on training a Meta-Learner on top of pre-trained Base-Learners. DeepStack offers an interface to fit the Meta-Learner on the predictions of the Base-Learners. In the following an Example based on top of pre-trained Keras Models (there is also an interface for generic models):


from deepstack.base import KerasMember  # For a generic (i.e., Non-Keras Model) check the class `Member`
from deepstack.ensemble import StackEnsemble

model1 = ...  # A Keras pre-trained Model (Base-Learner)
train_batches1 =  ...  # A numpy tuple (X_train, y_train) or Keras Data Iterator - Training Data for Meta-Learner
val_batches1 =  ...  # A numpy tuple (X_val, y_val) or Keras Data Iterator - Validation Data for Meta-Learner
member1 = KerasMember(name="Model1", keras_model=model1, train_batches=train_batches1, val_batches=val_batches1)

model2 = ...  
train_batches2 =  ...  
val_batches2 =  ...  
member2 = KerasMember(name="Model2", keras_model=model2, train_batches=train_batches2, val_batches=val_batches2)

stack = StackEnsemble()
stack.add_member(member1)  # Assumption: the data iterators of base-learners iterate over the same data and have same shape and classes.
stack.add_member(member2)  # Fits meta-learner based on training batches from its members (base-learners)
stack.describe()  # Prints information about ensemble performance based on validation data

Check an example on the CIFAR-10 dataset:

Randomized Weighted Ensemble

Ensemble Technique that weights the prediction of each ensemble member, combining the weights to calculate a combined prediction. Weight optimization search is performed with randomized search based on the dirichlet distribution on a validation dataset.

It follows the same interface of the StackEnsemble. An example can be found in

Citing DeepStack

If you use DeepStack in a scientific publication, we would appreciate citations:

    title   = {DeepStack: Ensembles for Deep Learning},
    author  = {Julio Borges},
    url = {},
    date = {2019}

Project details

Download files

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

Files for deepstack, version 0.0.9
Filename, size File type Python version Upload date Hashes
Filename, size deepstack-0.0.9-py3-none-any.whl (8.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size deepstack-0.0.9.tar.gz (7.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page