deepmol.base package

Submodules

deepmol.base.estimator module

class Estimator[source]

Bases: Serializer

Abstract base class for estimators. An estimator is an object that can be fitted to a Dataset object.

fit(dataset: Dataset) Estimator[source]

Fit the estimator to the data.

Parameters:

dataset (Dataset) – The dataset to fit the estimator to.

Returns:

self – The fitted estimator.

Return type:

Estimator

is_fitted() bool[source]

Whether the estimator is fitted.

Returns:

is_fitted – Whether the estimator is fitted.

Return type:

bool

deepmol.base.predictor module

class Predictor[source]

Bases: object

Abstract base class for predictors. A predictor is an object that can make predictions on a Dataset object. All predictors must implement the predict(), predict_proba(), and evaluate() methods.

abstract evaluate(dataset: Dataset, metrics: List[Metric] | Metric, per_task_metrics: bool = False) Tuple[Dict, None | Dict][source]

Evaluates the predictor of this model on specified dataset using specified metrics.

Parameters:
  • dataset (Dataset) – Dataset object.

  • metrics (Union[List[Metric], Metric]) – The set of metrics provided.

  • per_task_metrics (bool) – If true, return computed metric for each task on multitask dataset.

fit(dataset: Dataset, **kwargs) Predictor[source]

Fits a model on data in a Dataset object.

Parameters:

dataset (Dataset) – the Dataset to train on

Returns:

self

Return type:

Predictor

is_fitted() bool[source]

Whether the predictor is fitted.

Returns:

True if the predictor is fitted, False otherwise.

Return type:

bool

abstract classmethod load(model_dir: str) Predictor[source]

Loads a predictor from disk.

Parameters:

model_dir (str) – Directory where the predictor is stored.

Returns:

The loaded predictor.

Return type:

Predictor

property model_dir: str

Directory where the model will be stored.

Returns:

Directory where the model is stored.

Return type:

str

property model_type: str

Type of model.

Returns:

Type of model.

Return type:

str

abstract predict(dataset: Dataset) ndarray[source]

Uses self to make predictions on provided Dataset object.

Parameters:

dataset (Dataset) – Dataset to make prediction on

Returns:

A numpy array of predictions.

Return type:

np.ndarray

abstract predict_proba(dataset: Dataset) ndarray[source]

Uses self to make predictions on provided Dataset object.

Parameters:

dataset (Dataset) – Dataset to make prediction on

Returns:

A numpy array of predictions.

Return type:

np.ndarray

abstract save(model_path: str)[source]

Saves the predictor to disk.

Parameters:

model_path (str) – Path where the predictor will be stored.

deepmol.base.transformer module

class DatasetTransformer(func, **kwargs)[source]

Bases: Transformer

A transformer that transforms a dataset by applying a function to it.

class PassThroughTransformer[source]

Bases: Transformer

A transformer that does nothing.

class Transformer[source]

Bases: Estimator

Abstract base class for transformers. A transformer is an object that can transform a Dataset object.

fit_transform(dataset: Dataset) Dataset[source]

Fit the transformer to the dataset and transform it. Equivalent to calling fit(dataset) and then transform(dataset).

Parameters:

dataset (Dataset) – The dataset to fit and transform.

Returns:

dataset – The transformed dataset.

Return type:

Dataset

transform(dataset: Dataset) Dataset[source]

Transform the dataset. The transformer needs to be fitted before calling this method.

Parameters:

dataset (Dataset) – The dataset to transform.

Returns:

dataset – The transformed dataset.

Return type:

Dataset

Module contents