simpleml.utils.training.create_persistable

Module with helper classes to create new persistables

Module Contents

Classes

DatasetCreator

MetricCreator

ModelCreator

PersistableCreator

PipelineCreator

Attributes

LOGGER

__author__

simpleml.utils.training.create_persistable.LOGGER[source]
simpleml.utils.training.create_persistable.__author__ = Elisha Yadgaran[source]
class simpleml.utils.training.create_persistable.DatasetCreator[source]

Bases: PersistableCreator

classmethod create(cls, registered_name, **kwargs)[source]

Stateless method to create a new persistable with the desired parameters kwargs are passed directly to persistable

Parameters
  • registered_name (str) – Class name registered in SimpleML

  • dataset_pipeline – dataset pipeline object

Return type

simpleml.datasets.base_dataset.Dataset

classmethod determine_filters(cls, strict=True, **kwargs)[source]

stateless method to determine which filters to apply when looking for existing persistable

Returns: database class, filter dictionary

Parameters
  • registered_name – Class name registered in SimpleML

  • strict (bool) – whether to assume same class and name = same persistable,

Return type

Tuple[simpleml.datasets.base_dataset.Dataset, Dict[str, Any]]

or, load the data and compare the hash

class simpleml.utils.training.create_persistable.MetricCreator[source]

Bases: PersistableCreator

classmethod create(cls, registered_name, **kwargs)[source]

Stateless method to create a new persistable with the desired parameters kwargs are passed directly to persistable

Parameters
  • registered_name (str) – Class name registered in SimpleML

  • model – model class

Return type

simpleml.metrics.base_metric.Metric

classmethod determine_filters(cls, strict=False, **kwargs)[source]

stateless method to determine which filters to apply when looking for existing persistable

Returns: database class, filter dictionary

Parameters
  • registered_name – Class name registered in SimpleML

  • strict (bool) – whether to fit objects first before assuming they are identical

Return type

Tuple[simpleml.metrics.base_metric.Metric, Dict[str, Any]]

In theory if all inputs and classes are the same, the outputs should deterministically be the same as well (up to random iter). So, you dont need to fit objects to be sure they are the same

class simpleml.utils.training.create_persistable.ModelCreator[source]

Bases: PersistableCreator

classmethod create(cls, registered_name, **kwargs)[source]

Stateless method to create a new persistable with the desired parameters kwargs are passed directly to persistable

Parameters
  • registered_name (str) – Class name registered in SimpleML

  • pipeline – pipeline object

Return type

simpleml.models.base_model.Model

classmethod determine_filters(cls, strict=False, **kwargs)[source]

stateless method to determine which filters to apply when looking for existing persistable

Returns: database class, filter dictionary

Parameters
  • registered_name – Class name registered in SimpleML

  • strict (bool) – whether to fit objects first before assuming they are identical

Return type

Tuple[simpleml.models.base_model.Model, Dict[str, Any]]

In theory if all inputs and classes are the same, the outputs should deterministically be the same as well (up to random iter). So, you dont need to fit objects to be sure they are the same

class simpleml.utils.training.create_persistable.PersistableCreator[source]

Bases: object

abstract create(cls, **kwargs)[source]

method to create a new persistable with the desired parameters kwargs are passed directly to persistable

abstract determine_filters(cls, strict=False, **kwargs)[source]

method to determine which filters to apply when looking for existing persistable

Parameters

strict (bool) – whether to fit objects first before assuming they are identical

In theory if all inputs and classes are the same, the outputs should deterministically be the same as well (up to random iter). So, you dont need to fit objects to be sure they are the same

Default design iterates through 2 (or 3) options when retrieving persistables:
  1. By name and version (unique properties that define persistables)

2) By name, registered_name, and computed hash 2.5) Optionally, just use name and registered_name (assumes class

definition is the same and would result in an identical persistable)

Returns: database class, filter dictionary

static retrieve(cls, filters)[source]

Query database using the table model (cls) and filters for a matching persistable

Parameters

filters (Dict[str, Any]) –

Return type

simpleml.orm.persistable.ORMPersistable

classmethod retrieve_dataset(cls, dataset=None, dataset_id=None, dataset_kwargs=None, **kwargs)[source]
Parameters
Return type

simpleml.datasets.base_dataset.Dataset

static retrieve_dependency(dependency_cls, **dependency_kwargs)[source]

Base method to query for dependency Raises TrainingError if dependency does not exist

Parameters

dependency_cls (PersistableCreator) –

Return type

simpleml.persistables.base_persistable.Persistable

static retrieve_from_registry(registered_name)[source]

stateless method to query registry for class definitions. handles errors

Parameters

registered_name (str) –

Return type

simpleml.persistables.base_persistable.Persistable

classmethod retrieve_model(cls, model=None, model_id=None, model_kwargs=None, **kwargs)[source]
Parameters
Return type

simpleml.models.base_model.Model

classmethod retrieve_or_create(self, **kwargs)[source]

Wrapper method to first attempt to retrieve a matching persistable and then create a new one if it isn’t found

Return type

simpleml.persistables.base_persistable.Persistable

classmethod retrieve_pipeline(cls, pipeline=None, pipeline_id=None, pipeline_kwargs=None, **kwargs)[source]
Parameters
Return type

simpleml.pipelines.base_pipeline.Pipeline

class simpleml.utils.training.create_persistable.PipelineCreator[source]

Bases: PersistableCreator

classmethod create(cls, registered_name, **kwargs)[source]

Stateless method to create a new persistable with the desired parameters kwargs are passed directly to persistable

Parameters
  • registered_name (str) – Class name registered in SimpleML

  • dataset – dataset object

Return type

simpleml.pipelines.base_pipeline.Pipeline

classmethod determine_filters(cls, strict=False, **kwargs)[source]

stateless method to determine which filters to apply when looking for existing persistable

Returns: database class, filter dictionary

Parameters
  • registered_name – Class name registered in SimpleML

  • strict (bool) – whether to fit objects first before assuming they are identical

Return type

Tuple[simpleml.pipelines.base_pipeline.Pipeline, Dict[str, Any]]

In theory if all inputs and classes are the same, the outputs should deterministically be the same as well (up to random iter). So, you dont need to fit objects to be sure they are the same