Tuner Parameter_Grid

class dffml.tuner.parameter_grid.ParameterGrid(config: Optional[Type[BaseConfig]])[source]
CONFIG

alias of ParameterGridConfig

CONTEXT

alias of ParameterGridContext

class dffml.tuner.parameter_grid.ParameterGridConfig(parameters: dict)[source]
no_enforce_immutable()

By default, all properties of a config object are immutable. If you would like to mutate immutable properties, you must explicitly call this method using it as a context manager.

Examples

>>> from dffml import config
>>>
>>> @config
... class MyConfig:
...     C: int
>>>
>>> config = MyConfig(C=2)
>>> with config.no_enforce_immutable():
...     config.C = 1
class dffml.tuner.parameter_grid.ParameterGridContext(parent: Tuner)[source]

Parameter Grid Tuner

async optimize(model: ModelContext, feature: Feature, accuracy_scorer: Union[AccuracyScorer, AccuracyContext], train_data: Union[BaseSource, Record, Dict[str, Any]], test_data: Union[BaseSource, Record, Dict[str, Any]])[source]

Method to optimize hyperparameters by parameter grid. Uses a grid of hyperparameters in the form of a dictionary present in config, Trains each permutation of the grid of parameters and compares accuracy. Sets model to the best parameters and returns highest accuracy.

Parameters:
  • model (ModelContext) – The Model which needs to be used.

  • feature (Feature) – The Target feature in the data.

  • accuracy_scorer (AccuracyContext) – The accuracy scorer that needs to be used.

  • train_data (SourcesContext) – The train_data to train models on with the hyperparameters provided.

  • sources (SourcesContext) – The test_data to score against and optimize hyperparameters.

Returns:

The highest score value

Return type:

float