ProGED
SRToolkit.approaches.ProGED
ProGED approach — probabilistic grammar-based equation discovery by Brence et al.
ProGEDConfig
dataclass
Bases: ApproachConfig
Configuration dataclass for the ProGED approach.
Examples:
>>> cfg = ProGEDConfig()
>>> cfg.name
'ProGED'
>>> d = cfg.to_dict()
>>> ProGEDConfig.from_dict(d).grammar
ProGED
Bases: SR_approach
A slimmed-down version of ProGED — probabilistic grammar-based equation discovery.
Randomly samples expressions from a probabilistic context-free grammar (PCFG) and evaluates them using the provided evaluator. The full version of the approach is available at https://github.com/brencej/ProGED; see also Brence et al. (2021), https://doi.org/10.1016/j.knosys.2021.107077.
Examples:
>>> from SRToolkit.dataset import Feynman
>>> benchmark = Feynman()
>>> dataset = benchmark.create_dataset('I.16.6')
>>> dataset.max_evaluations = 100
>>> model = ProGED()
>>> model.adapt(dataset.X, dataset.symbol_library) # Since we don't put a custom grammar into ProGED we will need an automatically created PCFG.
>>> results = dataset.evaluate_approach(model, num_experiments=1, initial_seed=18, verbose=False)
>>> r = results[0]
>>> r.dataset_name
'I.16.6'
>>> r.approach_name
'ProGED'
>>> r.best_expr
'C*X_0'
>>> r.num_evaluated
74
>>> bool(r.success)
False
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grammar
|
Optional[str]
|
Grammar used for sampling. Either a SymbolLibrary (grammar is derived automatically) or a custom grammar string. |
None
|
Source code in SRToolkit/approaches/ProGED.py
prepare
search
Randomly sample expressions from the grammar and evaluate them until the budget is exhausted or the success threshold is reached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sr_evaluator
|
SR_evaluator
|
SR_evaluator used to score candidate expressions. |
required |
seed
|
Optional[int]
|
Optional random seed for reproducible sampling. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
None |