autointent.modules.abc.Module#

class autointent.modules.abc.Module#

Bases: abc.ABC

Base module.

name: str#
metadata_dict_name: str = 'metadata.json'#
metadata: autointent.custom_types.BaseMetadataDict#
abstract fit(*args, **kwargs)#

Fit the model.

Parameters:
  • args (tuple[Any]) – Args to fit

  • kwargs (dict[str, Any]) – Kwargs to fit

Return type:

None

abstract score(context, split, metric_fn)#

Calculate metric on test set and return metric value.

Parameters:
  • context (autointent.context.Context) – Context to score

  • split (Literal['validation', 'test']) – Split to score on

  • metric_fn (autointent.metrics.METRIC_FN) – Metric function

Return type:

float

abstract get_assets()#

Return useful assets that represent intermediate data into context.

Return type:

autointent.context.optimization_info.Artifact

abstract clear_cache()#

Clear cache.

Return type:

None

abstract dump(path)#

Dump all data needed for inference.

Parameters:

path (str) – Path to dump

Return type:

None

abstract load(path)#

Load data from dump.

Parameters:

path (str) – Path to load

Return type:

None

abstract predict(*args, **kwargs)#

Predict on the input.

Parameters:
  • args (list[str] | numpy.typing.NDArray[Any]) – args to predict.

  • kwargs (dict[str, Any]) – kwargs to predict.

Return type:

numpy.typing.NDArray[Any]

predict_with_metadata(*args, **kwargs)#

Predict on the input with metadata.

Parameters:
  • args (list[str] | numpy.typing.NDArray[Any]) – args to predict.

  • kwargs (dict[str, Any]) – kwargs to predict.

Return type:

tuple[numpy.typing.NDArray[Any], list[dict[str, Any]] | None]

classmethod from_context(context, **kwargs)#
Abstractmethod:

Parameters:
Return type:

Module

Initialize self from context.

Parameters:
Return type:

Module

get_embedder_name()#

Experimental method.

Return type:

str | None