tods.reinforcement module

tods.reinforcement.RuleBasedFilter

class tods.reinforcement.RuleBasedFilter.Hyperparams(*args: Any, **kwargs: Any)

Bases: d3m.metadata.hyperparams.Hyperparams

A base class to be subclassed and used as a type for Hyperparams type argument in primitive interfaces. An instance of this subclass is passed as a hyperparams argument to primitive’s constructor.

You should subclass the class and configure class attributes to hyper-parameters you want. They will be extracted out and put into the configuration attribute. They have to be an instance of the Hyperparameter class for this to happen.

You can define additional methods and attributes on the class. Prefix them with _ to not conflict with future standard ones.

When creating an instance of the class, all hyper-parameters have to be provided. Default values have to be explicitly passed.

configuration

A hyper-parameters configuration.

class tods.reinforcement.RuleBasedFilter.RuleBasedFilter(*args, **kwds)

Bases: d3m.primitive_interfaces.transformer.TransformerPrimitiveBase

Filter the selected columns according to the rule.

metadata

Primitive’s metadata. Available as a class attribute.

logger

Primitive’s logger. Available as a class attribute.

hyperparams

Hyperparams passed to the constructor.

random_seed

Random seed passed to the constructor.

docker_containers

A dict mapping Docker image keys from primitive’s metadata to (named) tuples containing container’s address under which the container is accessible by the primitive, and a dict mapping exposed ports to ports on that address.

volumes

A dict mapping volume keys from primitive’s metadata to file and directory paths where downloaded and extracted files are available to the primitive.

temporary_directory

An absolute path to a temporary directory a primitive can use to store any files for the duration of the current pipeline run phase. Directory is automatically cleaned up after the current pipeline run phase finishes.

Parameters
  • rule (String) – The rule to follow when performing the filter. Write it like how we write ‘if’ in python. And wrap column index with two ‘#’: #col_num#. e.g. “#1# > 10” means that the numbers in column 1 must be greater than 10. The indicies of columns should be same with those in ‘use_columns’.

  • use_columns (Set) – A set of column indices to force primitive to operate on. If any specified column cannot be parsed, it is skipped. The indicies of columns should be same with those in ‘rule’.

  • exclude_columns (Set) – A set of column indices to not operate on. Applicable only if “use_columns” is not provided.

  • return_result (Enumeration) – Should parsed columns be appended, should they replace original columns, or should only parsed columns be returned?

  • add_index_columns (Bool) – Also include primary index columns if input data has them. Applicable only if “return_result” is set to “new”.

  • error_on_no_input (Bool() – Throw an exception if no input column is selected/provided. Defaults to true to behave like sklearn. To prevent pipelines from breaking set this to False.

  • return_semantic_type (Enumeration[str]() – Decides what semantic type to attach to generated attributes’

produce(*, inputs: d3m.container.pandas.DataFrame, timeout: float = None, iterations: int = None) → d3m.primitive_interfaces.base.CallResult[d3m.container.pandas.DataFrame]

Process the testing data. :param inputs: Container DataFrame.

Returns

Container DataFrame after BKFilter.

Parameters
  • inputs – The inputs of shape [num_inputs, …].

  • timeout – A maximum time this primitive should take to produce outputs during this method call, in seconds.

  • iterations – How many of internal iterations should the primitive do.

Returns

Return type

The outputs of shape [num_inputs, …] wrapped inside CallResult.