Commands API
Auto-generated reference from source docstrings.
lefts.leaf(model_constructor, label)
Converts a model into the format required for transformation by lefts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_constructor
|
Callable[..., Any]
|
A constructor that creates a model with |
required |
label
|
str
|
A label for keeping track of this model. |
required |
Source code in src/lefts/interface.py
lefts.lift(model, values, name, train_filter, test_filter, validation_filter=None, aggregate_with=None)
Creates multiple copies of a model that are trained on (possibly overlapping) train, test and validation sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
A lefts Model object. |
required |
values
|
Values to lift the model over. One copy of the model will be trained for each value. |
required | |
name
|
The name of the lift transformation. Has no effect on model training, but controls how the resulting
models are labelled and addressed: each leaf beneath the lift gets a label of the form
|
required | |
train_filter
|
A function mapping each value in |
required | |
test_filter
|
A function mapping each value in |
required | |
validation_filter
|
A function mapping each value in |
None
|
|
aggregate_with
|
A function that postprocesses the output columns of the lift. It is called on the set of columns
output by the lifted |
None
|
Source code in src/lefts/interface.py
lefts.split(name, model, train_filter, test_filter, validation_filter=None)
Restricts a model to train, test and (optionally) validate on defined subsets of the available data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
A name used to keep track of this lefts operation in the workflow. Has no effect on model training. |
required |
model
|
Model
|
A lefts Model object. |
required |
train_filter
|
Expr
|
A boolean Polars expression that indicates whether a given row is in the train set. |
required |
test_filter
|
Expr
|
A boolean Polars expression that indicates whether a given row is in the test set. |
required |
validation_filter
|
Expr | None
|
A boolean Polars expression that indicates whether a given row is in the validation set. |
None
|
Source code in src/lefts/interface.py
lefts.ensemble(name, *models, aggregate_with=None)
Binds multiple models into a unified model that fits and predicts all of them in parallel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
A name used to keep track of this lefts operation in the workflow. Has no effect on model training. |
required |
models
|
lefts Model objects. |
()
|
|
aggregate_with
|
A function that postprocesses the output columns of the ensemble |
None
|
Source code in src/lefts/interface.py
lefts.tune(name, consumer, source, logic)
Learn hyperparameters by fitting the source model, applying customisable logic, then passing the resulting dictionary of hyperparameters to the consumer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
A name used to keep track of this lefts operation in the workflow. Has no effect on model training. |
required |
consumer
|
Model
|
A lefts Model object. Its leaf factories are instantiated using the outputs of |
required |
source
|
Model
|
A lefts Model object. It is fitted first; the fitted model is then handed to |
required |
logic
|
Callable[[Model, DataFrame], dict]
|
A callable |
required |
Source code in src/lefts/interface.py
lefts.feed(name, source, consumer)
Chains two models: the source's predictions are available to the consumer as a feature or target during .fit and .predict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
|
required |
source
|
Model
|
|
required |
consumer
|
Model
|
|
required |