Skip to content

ensemble_learner

EnsembleModel(*models)

Bases: Model

Ensemble model that combines multiple models.

Initialize the ensemble model.

Parameters:

Name Type Description Default
models Model

The tuple of models to combine.

()
Source code in src/flowcean/ensemble/ensemble_learner.py
13
14
15
16
17
18
19
def __init__(self, *models: Model) -> None:
    """Initialize the ensemble model.

    Args:
        models: The tuple of models to combine.
    """
    self.models = models

EnsembleLearner(*learners)

Bases: SupervisedLearner

Ensemble learner that combines multiple supervised learners.

The ensemble learner trains each of its constituent learners sequentially. After each learner is trained, its residual errors are calculated and used as the target outputs for the next learner in the sequence.

The final model produced by the ensemble learner combines the predictions of all constituent models by summing their outputs.

This learner works with any supervised learner and arbitrary data types supported by those learners, as long as the Data type is consistent across all learners and implements __add__ and __sub__ operations. Special handling is included for Polars DataFrames and LazyFrames to be compatible with the default flowcean learners.

Initialize the ensemble learner.

Parameters:

Name Type Description Default
learners SupervisedLearner

A tuple of supervised learner instances to combine.

()
Source code in src/flowcean/ensemble/ensemble_learner.py
64
65
66
67
68
69
70
def __init__(self, *learners: SupervisedLearner) -> None:
    """Initialize the ensemble learner.

    Args:
        learners: A tuple of supervised learner instances to combine.
    """
    self.learners = learners