SciKit-Learn

SklearnEstimator

class SklearnEstimator(module: sklearn.base.BaseEstimator)[source]

Bases: delira.models.abstract_network.AbstractNetwork

Wrapper Class to wrap all sklearn estimators and provide delira compatibility

_init_kwargs = {}
static closure(model, data_dict: dict, optimizers: dict, losses={}, metrics={}, fold=0, **kwargs)[source]

default closure method to do a single training step; Could be overwritten for more advanced models

Parameters
  • model (SkLearnEstimator) – trainable model

  • data_dict (dict) – dictionary containing the data

  • optimizers (dict) – dictionary of optimizers to optimize model’s parameters; ignored here, just passed for compatibility reasons

  • losses (dict) – dict holding the losses to calculate errors; ignored here, just passed for compatibility reasons

  • metrics (dict) – dict holding the metrics to calculate

  • fold (int) – Current Fold in Crossvalidation (default: 0)

  • **kwargs – additional keyword arguments

Returns

  • dict – Metric values (with same keys as input dict metrics)

  • dict – Loss values (with same keys as input dict losses; will always be empty here)

  • dict – dictionary containing all predictions

property init_kwargs

Returns all arguments registered as init kwargs

Returns

init kwargs

Return type

dict

property iterative_training

Property indicating, whether a the current module can be trained iteratively (batchwise)

Returns

True: if current module can be trained iteratively False: else

Return type

bool

static prepare_batch(batch: dict, input_device, output_device)[source]

Helper Function to prepare Network Inputs and Labels (convert them to correct type and shape and push them to correct devices)

Parameters
  • batch (dict) – dictionary containing all the data

  • input_device (Any) – device for module inputs (will be ignored here; just given for compatibility)

  • output_device (Any) – device for module outputs (will be ignored here; just given for compatibility)

Returns

dictionary containing data in correct type and shape and on correct device

Return type

dict