Result Augmentation
SRToolkit.evaluation.result_augmentation
Concrete ResultAugmenter implementations that post-process SR results with additional information.
Available augmenters: ExpressionToLatex, ExpressionSimplifier, RMSE, BED, R2. Custom augmenters work automatically without registration — just subclass ResultAugmenter and implement the required methods.
ExpressionToLatex
ExpressionToLatex(symbol_library: SymbolLibrary, scope: str = 'top', verbose: bool = False, name: str = 'ExpressionToLatex')
Bases: ResultAugmenter
Converts expressions inside the results to LaTeX strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol_library
|
SymbolLibrary
|
Symbol library used to produce LaTeX templates for each token. |
required |
scope
|
str
|
Which expressions to convert.
|
'top'
|
verbose
|
bool
|
If |
False
|
name
|
str
|
Key used in
|
'ExpressionToLatex'
|
Source code in SRToolkit/evaluation/result_augmentation.py
write_results
Write LaTeX representations into results and its models.
Stores {"best_expr_latex": ...} in
EvalResult augmentations.
Also stores {"expr_latex": ...} in each model's augmentations when
scope is "top" or "all".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
EvalResult
|
The EvalResult to augment. |
required |
Source code in SRToolkit/evaluation/result_augmentation.py
format_eval_result
classmethod
Format experiment-level LaTeX augmentation data for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
Augmentation dict containing |
required |
Returns:
| Type | Description |
|---|---|
str
|
A human-readable string, or empty string if no data is present. |
Source code in SRToolkit/evaluation/result_augmentation.py
format_model_result
classmethod
Format per-model LaTeX augmentation data for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
Augmentation dict containing |
required |
Returns:
| Type | Description |
|---|---|
str
|
A human-readable string, or empty string if no data is present. |
Source code in SRToolkit/evaluation/result_augmentation.py
to_dict
Creates a dictionary representation of the ExpressionToLatex augmenter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_path
|
str
|
Unused and ignored |
required |
name
|
str
|
Unused and ignored |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary containing the necessary information to recreate the augmenter. |
Source code in SRToolkit/evaluation/result_augmentation.py
from_dict
staticmethod
Creates an instance of the ExpressionToLatex augmenter from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
A dictionary containing the necessary information to recreate the augmenter. |
required |
Returns:
| Type | Description |
|---|---|
ExpressionToLatex
|
An instance of the ExpressionToLatex augmenter. |
Source code in SRToolkit/evaluation/result_augmentation.py
ExpressionSimplifier
ExpressionSimplifier(symbol_library: SymbolLibrary, scope: str = 'top', verbose: bool = False, name: str = 'ExpressionSimplifier')
Bases: ResultAugmenter
Algebraically simplifies expressions inside the results using SymPy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol_library
|
SymbolLibrary
|
Symbol library used by the simplifier to resolve token types. |
required |
scope
|
str
|
Which expressions to simplify.
|
'top'
|
verbose
|
bool
|
If |
False
|
name
|
str
|
Key used in
|
'ExpressionSimplifier'
|
Source code in SRToolkit/evaluation/result_augmentation.py
write_results
Write simplified expressions into results and its models.
Stores {"simplified_best_expr": ...} in
EvalResult augmentations if
simplification succeeds. Also stores {"simplified_expr": ...} in each model's
augmentations when scope is "top" or "all".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
EvalResult
|
The EvalResult to augment. |
required |
Source code in SRToolkit/evaluation/result_augmentation.py
format_eval_result
classmethod
Format experiment-level simplification data for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
Augmentation dict containing |
required |
Returns:
| Type | Description |
|---|---|
str
|
A human-readable string, or empty string if no data is present. |
Source code in SRToolkit/evaluation/result_augmentation.py
format_model_result
classmethod
Format per-model simplification data for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
Augmentation dict containing |
required |
Returns:
| Type | Description |
|---|---|
str
|
A human-readable string, or empty string if no data is present. |
Source code in SRToolkit/evaluation/result_augmentation.py
to_dict
Creates a dictionary representation of the ExpressionSimplifier augmenter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_path
|
str
|
Unused and ignored |
required |
name
|
str
|
Unused and ignored |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary containing the necessary information to recreate the augmenter. |
Source code in SRToolkit/evaluation/result_augmentation.py
from_dict
staticmethod
Creates an instance of the ExpressionSimplifier augmenter from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
A dictionary containing the necessary information to recreate the augmenter. |
required |
Returns: An instance of the ExpressionSimplifier augmenter.
Source code in SRToolkit/evaluation/result_augmentation.py
RMSE
Bases: ResultAugmenter
Computes RMSE for the top models using a separate evaluator (e.g. a held-out test set).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluator
|
SR_evaluator
|
SR_evaluator used to
score the models. Must be initialized with |
required |
scope
|
str
|
Which expressions to score.
|
'top'
|
name
|
str
|
Key used in
|
'RMSE'
|
Raises:
| Type | Description |
|---|---|
Exception
|
If |
Source code in SRToolkit/evaluation/result_augmentation.py
write_results
Write RMSE scores into results and its models.
Stores {"min_error": ...} in
EvalResult augmentations and
{"error": ..., "parameters": ...} in each model's augmentations when scope
is "top" or "all".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
EvalResult
|
The EvalResult to augment. |
required |
Source code in SRToolkit/evaluation/result_augmentation.py
format_eval_result
classmethod
Format experiment-level RMSE data for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
Augmentation dict containing |
required |
Returns:
| Type | Description |
|---|---|
str
|
A human-readable string, or empty string if no data is present. |
Source code in SRToolkit/evaluation/result_augmentation.py
format_model_result
classmethod
Format per-model RMSE data for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
Augmentation dict containing |
required |
Returns:
| Type | Description |
|---|---|
str
|
A human-readable string with RMSE and fitted parameters. |
Source code in SRToolkit/evaluation/result_augmentation.py
to_dict
Creates a dictionary representation of the RMSE augmenter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_path
|
str
|
Used to save the data of the evaluator to disk. |
required |
name
|
str
|
Used to save the data of the evaluator to disk. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary containing the necessary information to recreate the augmenter. |
Source code in SRToolkit/evaluation/result_augmentation.py
from_dict
staticmethod
Creates an instance of the RMSE augmenter from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
A dictionary containing the necessary information to recreate the augmenter. |
required |
Returns:
| Type | Description |
|---|---|
RMSE
|
An instance of the RMSE augmenter. |
Source code in SRToolkit/evaluation/result_augmentation.py
BED
Bases: ResultAugmenter
Computes BED for the top models using a separate evaluator (e.g. a held-out test set).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluator
|
SR_evaluator
|
SR_evaluator used to
score the models. Must be initialized with |
required |
scope
|
str
|
Which expressions to score.
|
'top'
|
name
|
str
|
Key used in
|
'BED'
|
Raises:
| Type | Description |
|---|---|
Exception
|
If |
Source code in SRToolkit/evaluation/result_augmentation.py
write_results
Write BED scores into results and its models.
Stores {"best_expr_bed": ...} in
EvalResult augmentations and
{"bed": ...} in each model's augmentations when scope is "top" or "all".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
EvalResult
|
The EvalResult to augment. |
required |
Source code in SRToolkit/evaluation/result_augmentation.py
format_eval_result
classmethod
Format experiment-level BED data for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
Augmentation dict containing |
required |
Returns:
| Type | Description |
|---|---|
str
|
A human-readable string, or empty string if no data is present. |
Source code in SRToolkit/evaluation/result_augmentation.py
format_model_result
classmethod
Format per-model BED data for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
Augmentation dict containing |
required |
Returns:
| Type | Description |
|---|---|
str
|
A human-readable string, or empty string if no data is present. |
Source code in SRToolkit/evaluation/result_augmentation.py
to_dict
Creates a dictionary representation of the BED augmenter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_path
|
str
|
Used to save the data of the evaluator to disk. |
required |
name
|
str
|
Used to save the data of the evaluator to disk. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary containing the necessary information to recreate the augmenter. |
Source code in SRToolkit/evaluation/result_augmentation.py
from_dict
staticmethod
Creates an instance of the BED augmenter from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
A dictionary containing the necessary information to recreate the augmenter. |
required |
Returns:
| Type | Description |
|---|---|
BED
|
An instance of the BED augmenter. |
Source code in SRToolkit/evaluation/result_augmentation.py
R2
Bases: ResultAugmenter
Computes R² for the top models using a separate evaluator (e.g. a held-out test set).
The same evaluator instance can be shared with RMSE to avoid loading test data twice.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluator
|
SR_evaluator
|
SR_evaluator used to
score the models. Must be initialized with |
required |
scope
|
str
|
Which expressions to score.
|
'top'
|
name
|
str
|
Key used in
|
'R2'
|
Raises:
| Type | Description |
|---|---|
Exception
|
If |
Source code in SRToolkit/evaluation/result_augmentation.py
write_results
Write R² scores into results and its models.
Stores {"best_expr_r^2": ...} in
EvalResult augmentations and
{"r^2": ..., "parameters_r^2": ...} in each model's augmentations when scope
is "top" or "all".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
EvalResult
|
The EvalResult to augment. |
required |
Source code in SRToolkit/evaluation/result_augmentation.py
format_eval_result
classmethod
Format experiment-level R² data for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
Augmentation dict containing |
required |
Returns:
| Type | Description |
|---|---|
str
|
A human-readable string, or empty string if no data is present. |
Source code in SRToolkit/evaluation/result_augmentation.py
format_model_result
classmethod
Format per-model R² data for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
Augmentation dict containing |
required |
Returns:
| Type | Description |
|---|---|
str
|
A human-readable string with R² and fitted parameters. |
Source code in SRToolkit/evaluation/result_augmentation.py
to_dict
Creates a dictionary representation of the R2 augmenter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_path
|
str
|
Used to save the data of the evaluator to disk. |
required |
name
|
str
|
Used to save the data of the evaluator to disk. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary containing the necessary information to recreate the augmenter. |
Source code in SRToolkit/evaluation/result_augmentation.py
from_dict
staticmethod
Creates an instance of the R2 augmenter from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
A dictionary containing the necessary information to recreate the augmenter. |
required |
Returns:
| Type | Description |
|---|---|
R2
|
An instance of the R2 augmenter. |