API Reference¶
Trial¶
-
class
experitur.trial.
TrialProxy
(trial)¶ This is the trial object that the experiment interacts with.
-
apply
(prefix, callable_, *args, **kwargs)¶ Apply the callable using the parameters given py prefix.
Parameters: - prefix (str) – Prefix of the applied parameters.
- callable (callable) – Callable to be applied.
- *args – Positional arguments to the callable.
- **kwargs – Named defaults for the callable.
Returns: The return value of the callable.
The default values of the callable are determined using
inspect
. Additional defaults can be given using**kwargs
. These defaults are recorded into the trial.As all passed values are recorded, make sure that these have simple YAML-serializable types.
-
record_defaults
(prefix, *args, **defaults)¶ Set default parameters.
Default parameters can be assigned directly or guessed from a callable.
-
without_prefix
(prefix)¶ Extract parameters beginning with prefix and remove the prefix.
-
Experiment¶
-
class
experitur.experiment.
Experiment
(ctx, name=None, parameter_grid=None, parent=None, meta=None, active=True)¶ An experiment.
-
__call__
(callable)¶ Register an entry-point.
Allows an Experiment object to be used as a decorator:
@Experiment() def entry_point(trial): ...
-
independent_parameters
¶ Calculate independent parameters (parameters that are actually varied) of this experiment.
-
post_grid
(callable)¶ Update the post-grid hook.
The post-grid hook is called after the parameter grid has been calculated and before every cell of the grid is executed. This hook can be used to alter the parameter grid (add/remove/change cells).
Use
post_grid(None)
to reset the hook.The callable is expected to return an iterable of parameter dicts, one for each trial.
This can be used as a decorator:
@experiment() def exp(trial): ... @exp.post_grid def post_grid_handler(ctx, parameters_per_trial): ... return parameters_per_trial
Parameters: callable – A callable with the signature (ctx, parameters_per_trial) -> parameters_per_trial.
-
pre_trial
(callable)¶ Update the pre-trial hook.
The pre-trial hook is called after the parameters for a trial are calculated and before its ID is calculated and it is run. This hook can be used to alter the parameters.
Use
pre_trial(None)
to reset the hook.This can be used as a decorator:
@experiment() def exp(trial): ... @exp.pre_trial def pre_trial_handler(ctx, trial_parameters): ...
Parameters: callable – A callable with the signature (ctx, trial_parameters).
-
run
()¶ Runs this experiment.
Create trials for every combination in the parameter grid and run them.
-