onetick.ml.impl.models#

class DNNRegressor(init_params: dict, fit_params: dict)[source]#

Common Deep Neural Network model (Keras based)

Parameters
  • init_params (dict) –

    Dictionary with parameters for model initialization and customization. It includes:
    hid_layers_num: int

    Number of hidden layers.

    neurons_num_layerN: int

    Number of neurons in layer N (N - integer >= 1).

    dropout_layerN: float

    Dropout of layer N (N - integer >= 1). Value >= 0 and < 1.

    activation_layerN: Any

    Activation function of layer N (N - integer >= 1).

    optimizer: Any

    Optimizer used in network training.

  • fit_params (dict) – Dictionary with parameters for model.fit() function.

  • init_params – Parameters passed directly to the initialization of the native model.

  • fit_params – Parameters passed directly to native model .fit() method.

class XGBRegressor(init_params: dict, fit_params: dict)[source]#

XGBoost regressor model.

Parameters
  • init_params (dict) – Parameters passed directly to the initialization of the native model.

  • fit_params (dict) – Parameters passed directly to native model .fit() method.

init_model(dsf_params={}, init_params={})[source]#

Init XGBRegressor model.

Parameters
  • dsf_params (dict) – Dictionary which includes: overfitting_params and loss param (see experiment.init_fit())

  • init_params (dict) – Parameters passed directly to the initialization of the native XGBRegressor model.

get_fit_params()[source]#

Override this method to update _model_params before returning it.

class CatBoostRegressor(init_params: dict, fit_params: dict)[source]#

CatBoostRegressor model.

Parameters
  • init_params (dict) – Parameters passed directly to the initialization of the native model.

  • fit_params (dict) – Parameters passed directly to native model .fit() method.

init_model(dsf_params=None, init_params=None)[source]#

Init CatBoostRegressor model.

Parameters
  • dsf_params (dict) – Dictionary which includes: overfitting_params and loss param (see experiment.init_fit())

  • init_params (dict) – Parameters passed directly to the initialization of the native CatBoostRegressor model.

get_model_params()[source]#

Override this method to update _model_params before returning it.

class CascadeForestRegressor(init_params: dict, fit_params: dict)[source]#
Parameters
  • init_params (dict) – Parameters passed directly to the initialization of the native model.

  • fit_params (dict) – Parameters passed directly to native model .fit() method.

init_model(dsf_params={}, init_params={})[source]#

Initialize model with parameters.

Parameters
  • dsf_params (dict) – Dictionary which includes: overfitting_params and loss param (see experiment.init_fit())

  • init_params (dict) – Parameters passed directly to the initialization of the native model.

fit(x_train, y_train, eval_set=None)[source]#

Train model with X-Y examples (X - features, Y - targets).

Parameters
  • x_train (pandas.DataFrame, numpy.Array, or any model compatible type) – Data with features for model training.

  • y_train (pandas.DataFrame, numpy.Array, or any model compatible type) – Data with targets for model training. Must be same length as x_train.

  • eval_set (list of (X, y) tuple pairs, optional) – List of (X, y) tuple pairs to use as validation sets for early-stopping.

Returns

model_result – Only for models with fit() returning trained model (not inplace training). Depended on which model class used.

Return type

Any (depended on which model class used).

class DecisionTreeRegressor(init_params: dict, fit_params: dict)[source]#

DecisionTreeRegressor sklearn model.

Parameters
  • init_params (dict) – Parameters passed directly to the initialization of the native model.

  • fit_params (dict) – Parameters passed directly to native model .fit() method.

class RegressorModel(init_params: dict, fit_params: dict)[source]#

Abstract base class for features-targets models.

Parameters
  • init_params (dict) – Parameters passed directly to the initialization of the native model.

  • fit_params (dict) – Parameters passed directly to native model .fit() method.

init_model(dsf_params: dict, init_params: dict)[source]#

Initialize model with parameters.

Parameters
  • dsf_params (dict) – Dictionary which includes: overfitting_params and loss param (see experiment.init_fit())

  • init_params (dict) – Parameters passed directly to the initialization of the native model.

get_model_params()[source]#

Override this method to update _model_params before returning it.

get_fit_params()[source]#

Override this method to update _model_params before returning it.

fit(x_train, y_train, eval_set=None)[source]#

Train model with X-Y examples (X - features, Y - targets).

Parameters
  • x_train (pandas.DataFrame, numpy.Array, or any model compatible type) – Data with features for model training.

  • y_train (pandas.DataFrame, numpy.Array, or any model compatible type) – Data with targets for model training. Must be same length as x_train.

  • eval_set (list of (X, y) tuple pairs, optional) – List of (X, y) tuple pairs to use as validation sets for early-stopping.

Returns

model_result – Only for models with fit() returning trained model (not inplace training). Depended on which model class used.

Return type

Any (depended on which model class used).

predict(x_test: pandas.core.frame.DataFrame, **kwargs)[source]#

Predict Y by X using already trained model (X - features, Y - targets).

Parameters

x_test (DataFrame) – Data with features used to predict Y values.

Returns

y_pred – Predicted Y values.

Return type

numpy.Array

save_model(*args, **kwargs)[source]#

Saving of a model to a local file.

Parameters
  • args (list) – Arguments goes directly to native model.save_model() function.

  • kwargs (dict) – Keyword arguments goes directly to native model.save_model() function.

load_model(*args, experiment=None, **kwargs)[source]#

Loading a model from a local file.

Parameters
  • args (list) – Arguments goes directly to native model.load_model() function.

  • kwargs (dict) – Keyword arguments goes directly to native model.load_model() function.

Returns

Loaded ML-model (depended on which model class used)

Return type

Any

class RandomForestRegressor(init_params: dict, fit_params: dict)[source]#

RandomForestRegressor sklearn model.

Parameters
  • init_params (dict) – Parameters passed directly to the initialization of the native model.

  • fit_params (dict) – Parameters passed directly to native model .fit() method.

class LGBMRegressor(init_params: dict, fit_params: dict)[source]#

LightGBM regressor model.

Parameters
  • init_params (dict) – Parameters passed directly to the initialization of the native model.

  • fit_params (dict) – Parameters passed directly to native model .fit() method.

init_model(dsf_params=None, init_params=None)[source]#

Initialize model with parameters.

Parameters
  • dsf_params (dict) – Dictionary which includes: overfitting_params and loss param (see experiment.init_fit())

  • init_params (dict) – Parameters passed directly to the initialization of the native model.

get_model_params()[source]#

Override this method to update _model_params before returning it.

get_fit_params()[source]#

Override this method to update _model_params before returning it.

save_model(*args, **kwargs)[source]#

Saving of LGBMRegressor model to a local file.

Parameters
  • args (list) – Arguments goes directly to native model.booster_.save_model() function.

  • kwargs (dict) – Keyword arguments goes directly to native model.booster_.save_model() function.

load_model(path, experiment=None, **kwargs)[source]#

Loading a model from a local file.

Parameters
  • path (str, pathlib.Path) – Path to the model file.

  • kwargs (dict) – Keyword arguments goes directly to native lightgbm.Booster.

Returns

model – Loaded LGBMRegressor model.

Return type

Any (depended on which model class used)

class DummyRegressor(init_params: dict, fit_params: dict)[source]#

Dummy regressor class used for tests. Don’t fit or train, just implements methods to call.

Parameters
  • init_params (dict) – Parameters passed directly to the initialization of the native model.

  • fit_params (dict) – Parameters passed directly to native model .fit() method.

init_model(dsf_params={}, init_params={})[source]#

Initialize model with parameters.

Parameters
  • dsf_params (dict) – Dictionary which includes: overfitting_params and loss param (see experiment.init_fit())

  • init_params (dict) – Parameters passed directly to the initialization of the native model.

fit(x_train, y_train, eval_set=None)[source]#

Train model with X-Y examples (X - features, Y - targets).

Parameters
  • x_train (pandas.DataFrame, numpy.Array, or any model compatible type) – Data with features for model training.

  • y_train (pandas.DataFrame, numpy.Array, or any model compatible type) – Data with targets for model training. Must be same length as x_train.

  • eval_set (list of (X, y) tuple pairs, optional) – List of (X, y) tuple pairs to use as validation sets for early-stopping.

Returns

model_result – Only for models with fit() returning trained model (not inplace training). Depended on which model class used.

Return type

Any (depended on which model class used).