Tuner Parameter_Grid
- class dffml.tuner.parameter_grid.ParameterGrid(config: Optional[Type[dffml.base.BaseConfig]])[source]
- CONFIG
- CONTEXT
- 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: dffml.tuner.tuner.Tuner)[source]
Parameter Grid Tuner
- async optimize(model: dffml.model.model.ModelContext, feature: dffml.feature.feature.Feature, accuracy_scorer: Union[dffml.accuracy.accuracy.AccuracyScorer, dffml.accuracy.accuracy.AccuracyContext], train_data: Union[dffml.source.source.BaseSource, dffml.record.Record, Dict[str, Any]], test_data: Union[dffml.source.source.BaseSource, dffml.record.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