MLAlgo

class lightautoml.ml_algo.base.MLAlgo(default_params=None, freeze_defaults=True, timer=None, optimization_search_space={})[source]

Bases: abc.ABC

Abstract class for machine learning algorithm. Assume that features are already selected, but parameters my be tuned and set before training.

property name

Get model name.

Return type

str

property features

Get list of features.

Return type

List[str]

property is_fitted

Get flag is the model fitted or not.

Return type

bool

property params

Get model’s params dict.

Return type

dict

init_params_on_input(train_valid_iterator)[source]

Init params depending on input data.

Parameters

train_valid_iterator (TrainValidIterator) – Classic cv-iterator.

Return type

dict

Returns

Dict with model hyperparameters.

__init__(default_params=None, freeze_defaults=True, timer=None, optimization_search_space={})[source]
Parameters
  • default_params (Optional[dict]) – Algo hyperparams.

  • freeze_defaults (bool) –

    • True : params may be rewrited depending on dataset.

    • False: params may be changed only manually or with tuning.

  • timer (Optional[TaskTimer]) – Timer for Algo.

abstract fit_predict(train_valid_iterator)[source]

Abstract method.

Fit new algo on iterated datasets and predict on valid parts.

Parameters

train_valid_iterator (TrainValidIterator) – Classic cv-iterator.

Return type

LAMLDataset

abstract predict(test)[source]

Predict target for input data.

Parameters

test (LAMLDataset) – Dataset on test.

Return type

LAMLDataset

Returns

Dataset with predicted values.

score(dataset)[source]

Score prediction on dataset with defined metric.

Parameters

dataset (LAMLDataset) – Dataset with ground truth and predictions.

Return type

float

Returns

Metric value.

set_prefix(prefix)[source]

Set prefix to separate models from different levels/pipelines.

Parameters

prefix (str) – String with prefix.

set_timer(timer)[source]

Set timer.

Return type

MLAlgo