ProGED
SRToolkit.approaches.ProGED
This module contains the ProGED approach - Probabilistic grammar-based equation discovery by Brence et. al.
ProGED
Bases: SR_approach
A slimmed-down version of the ProGED approach. You can find the full version of the approach at https://github.com/brencej/ProGED and the paper presenting the approach at https://www.sciencedirect.com/science/article/pii/S0950705121003403.
The approach randomly samples expressions from a probabilistic grammar and evaluates them on the dataset.
Examples:
>>> from SRToolkit.dataset import SR_benchmark
>>> benchmark = SR_benchmark.feynman('../../data/feynman/')
>>> dataset = benchmark.create_dataset('I.16.6')
>>> dataset.max_evaluations = 100
>>> model = ProGED(dataset.symbol_library, verbose=False)
>>> results = dataset.evaluate_approach(model, num_experiments=1, initial_seed=18, verbose=False)
>>> results.print_results(0)
Dataset: I.16.6
Approach: ProGED
Best expression found: X_0/C/C
Error: 0.39676872335771524
Number of evaluated expressions: 77
Number of times evaluate_expr was called: 100
Success: False
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grammar
|
Union[str, SymbolLibrary]
|
The grammar to use for sampling expressions. Can be either a string or a SymbolLibrary object. Using a string let's you define a custom grammar. |
required |
verbose
|
bool
|
If True, prints the expression and its error if the expression is better than the current best. |
False
|
Source code in SRToolkit/approaches/ProGED.py
prepare
search
Samples expressions from the grammar using the Monte Carlo approach and evaluates them on the dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sr_evaluator
|
SR_evaluator
|
The evaluator used for scoring expressions. |
required |
seed
|
Optional[int]
|
The seed used for random number generation. |
None
|