deepmol.parameter_optimization package

Submodules

deepmol.parameter_optimization.base_hyperparameter_optimization module

class HyperparameterOptimizer(model_builder: callable, model_type: str, params_dict: Dict, metric: Metric, maximize_metric: bool, n_iter_search: int = 15, n_jobs: int = 1, verbose: int = 0, logdir: str | None = None, mode: str | None = None, **kwargs)[source]

Bases: ABC

Abstract superclass for hyperparameter search classes.

abstract fit(train_dataset: Dataset, valid_dataset: Dataset | None = None) Tuple[Model, Dict[str, Any], Dict[str, float]][source]

Conduct Hyperparameter search.

This method defines the common API shared by all hyperparameter optimization subclasses. Different classes will implement different search methods, but they must all follow this common API.

Parameters:
  • train_dataset (Dataset) – The training dataset.

  • valid_dataset (Dataset) – The validation dataset.

Returns:

A tuple containing the best model, the best hyperparameters, and all scores.

Return type:

Tuple[Model, Dict[str, Any], Dict[str, float]]

deepmol.parameter_optimization.deepchem_hyperparameter_optimization module

class DeepchemBaseSearchCV(model_builder: callable, params_dict: dict | ParameterGrid | ParameterSampler, metric: Metric | List[Metric], maximize_metric: bool, refit: bool, cv: int, mode: str, random_state: int | None = None, return_train_score: bool = False, **kwargs)[source]

Bases: HyperparameterOptimizer

Base class for hyperparameter search with cross-validation for DeepChemModels.

fit(train_dataset: Dataset, validation_dataset: Dataset | None = None)[source]

Run hyperparameter search with cross-validation.

Parameters:
  • train_dataset (Dataset) – The dataset to use for the hyperparameter search.

  • validation_dataset (Dataset) – The dataset to use for validation. If None, use the training dataset.

class DeepchemGridSearchCV(model_builder: callable, params_dict: dict | ParameterGrid, metric: Metric | List[Metric], maximize_metric: bool, refit: bool, cv: int, mode: str, random_state: int | None = None, return_train_score: bool = False)[source]

Bases: DeepchemBaseSearchCV

Hyperparameter search with cross-validation for DeepChemModels using a grid search.

class DeepchemRandomSearchCV(model_builder: callable, params_dict: dict | ParameterSampler, metric: Metric | List[Metric], maximize_metric: bool, refit: bool, cv: int, mode: str, random_state: int | None = None, return_train_score: bool = False, n_iter: int = 20)[source]

Bases: DeepchemBaseSearchCV

Hyperparameter search with cross-validation for DeepChemModels using a random search.

deepmol.parameter_optimization.hyperparameter_optimization module

class HyperparameterOptimizerCV(model_builder: callable, model_type: str, params_dict: Dict, metric: Metric, maximize_metric: bool, n_iter_search: int = 15, n_jobs: int = 1, verbose: int = 0, logdir: str | None = None, mode: str | None = None, cv=5, seed=123, refit=True, **kwargs)[source]

Bases: HyperparameterOptimizer

Provides simple grid hyperparameter search capabilities. This class performs a grid hyperparameter search over the specified hyperparameter space.

fit(train_dataset: Dataset, validation_dataset: Dataset | None = None) Tuple[Model, Dict, Dict][source]

Perform hyperparams search according to params_dict. Each key to hyperparams_dict is a model_param. The values should be a list of potential values for that hyperparameter.

Parameters:
  • train_dataset (Dataset) – Dataset to train on.

  • validation_dataset (Dataset, optional) – Dataset to validate on.

Returns:

A tuple containing the best model, the best hyperparameters, and all scores.

Return type:

Tuple[Model, Dict[str, Any], Dict[str, float]]

class HyperparameterOptimizerValidation(model_builder: callable, model_type: str, params_dict: Dict, metric: Metric, maximize_metric: bool, n_iter_search: int = 15, n_jobs: int = 1, verbose: int = 0, logdir: str | None = None, mode: str | None = None, **kwargs)[source]

Bases: HyperparameterOptimizer

Provides simple grid hyperparameter search capabilities. This class performs a grid hyperparameter search over the specified hyperparameter space.

fit(train_dataset: Dataset, valid_dataset: Dataset | None = None) Tuple[Model, Dict[str, Any], Dict[str, float]][source]

Perform hyperparams search according to params_dict. Each key to hyperparams_dict is a model_param. The values should be a list of potential values for that hyperparameter.

Parameters:
  • train_dataset (Dataset) – The training dataset.

  • valid_dataset (Dataset) – The validation dataset.

Returns:

A tuple containing the best model, the best hyperparameters, and all scores.

Return type:

Tuple[Model, Dict[str, Any], Dict[str, float]]

Module contents