Result Augmentation Module
SRToolkit.evaluation.result_augmentation
This module contains the ResultAugmenter class and the result augmentation implementations that inherit from it.
ResultAugmenter
Source code in SRToolkit/evaluation/result_augmentation.py
__init__()
augment_results(results, models, evaluator)
Augments the results dictionary with additional information. The model variable contains all models, for only top models, results["top_models"] should be used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
dict
|
The dictionary containing the results to augment. |
required |
models
|
List[dict]
|
The list of models that were evaluated. Variable models[i]["expr"] contains the expression model i, models[i]["error"] contains the error for model i, ... |
required |
evaluator
|
SR_evaluator
|
The evaluator used to evaluate the models. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The augmented results dictionary. |
Source code in SRToolkit/evaluation/result_augmentation.py
ExpressionToLatex
Bases: ResultAugmenter
Source code in SRToolkit/evaluation/result_augmentation.py
__init__(only_best_expression=False)
Transforms the expressions inside the results dictionary into LaTeX strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
only_best_expression
|
bool
|
If True, only the best expression is transformed. If False, all top expressions are |
False
|
Source code in SRToolkit/evaluation/result_augmentation.py
augment_results(results, models, evaluator)
Transforms the expressions inside the results dictionary into LaTeX strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
dict
|
The dictionary containing the results to augment. |
required |
models
|
List[dict]
|
The list of models that were evaluated. Variable models[i]["expr"] contains the expression model i, ... |
required |
evaluator
|
SR_evaluator
|
The evaluator used to evaluate the models. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The augmented results dictionary. The results dictionary contains an additional key "best_expr_latex" with the LaTeX representation of the best expression, and similarly keys "expr_latex" for expressions inside the top_models list if only_best_expression is False. |
Source code in SRToolkit/evaluation/result_augmentation.py
ExpressionSimplifier
Bases: ResultAugmenter
Source code in SRToolkit/evaluation/result_augmentation.py
__init__(only_best_expression=False, verbose=False)
Simplifies the expressions inside the results dictionary if possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
only_best_expression
|
bool
|
If True, only the best expression is simplified. If False, all top expressions are simplified. |
False
|
verbose
|
bool
|
If True, warns the user if simplification fails for a given expression. |
False
|
Source code in SRToolkit/evaluation/result_augmentation.py
augment_results(results, models, evaluator)
Simplifies the expressions inside the results dictionary if possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
dict
|
The dictionary containing the results to augment. |
required |
models
|
List[dict]
|
The list of models that were evaluated. Variable models[i]["expr"] contains the expression model i, ... |
required |
evaluator
|
SR_evaluator
|
The evaluator used to evaluate the models. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The augmented results dictionary. The results dictionary contains an additional key "simplified_best_expr" |
dict
|
if simplification was successful for the best expression, and similarly keys "simplified_expr" inside the |
dict
|
top_models list if only_best_expression is False. |
Source code in SRToolkit/evaluation/result_augmentation.py
RMSE
Bases: ResultAugmenter
Source code in SRToolkit/evaluation/result_augmentation.py
__init__(evaluator)
Computes the RMSE for the top models in the results dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluator
|
SR_evaluator
|
The evaluator used to evaluate the models (e.g., evaluator defined with test set data). This evaluator must be initialized with ranking_function = "rmse" |
required |
Raises:
| Type | Description |
|---|---|
Exception
|
If the evaluator is not initialized with ranking_function = "rmse" or if y in the evaluator is None. |
Source code in SRToolkit/evaluation/result_augmentation.py
augment_results(results, models, evaluator)
Computes the RMSE for the top models in the results dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
dict
|
The dictionary containing the results to augment. |
required |
models
|
List[dict]
|
The list of models that were evaluated. Variable models[i]["expr"] contains the expression model i, ... |
required |
evaluator
|
SR_evaluator
|
The evaluator used to evaluate the models. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The augmented results dictionary. The results dictionary contains an additional key "best_expr_rmse" with the |
dict
|
RMSE of the best expression, and keys "rmse" and "parameters_rmse" for each of the top_models inside the |
dict
|
results["top_models"] list. |
Source code in SRToolkit/evaluation/result_augmentation.py
BED
Bases: ResultAugmenter
Source code in SRToolkit/evaluation/result_augmentation.py
__init__(evaluator)
Computes BED for the top models in the results dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluator
|
SR_evaluator
|
The evaluator used to evaluate the models. This evaluator must be initialized with |
required |
Raises:
| Type | Description |
|---|---|
Exception
|
If the evaluator is not initialized with ranking_function = "bed". |
Source code in SRToolkit/evaluation/result_augmentation.py
augment_results(results, models, evaluator)
Computes BED for the top models in the results dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
dict
|
The dictionary containing the results to augment. |
required |
models
|
List[dict]
|
The list of models that were evaluated. Variable models[i]["expr"] contains the expression model i, ... |
required |
evaluator
|
SR_evaluator
|
The evaluator used to evaluate the models. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The augmented results dictionary. The results dictionary contains an additional key "best_expr_bed" with |
dict
|
BED of the best expression, and key "bed" for each of the top_models inside the results["top_models"] list. |
Source code in SRToolkit/evaluation/result_augmentation.py
R2
Bases: ResultAugmenter
Source code in SRToolkit/evaluation/result_augmentation.py
__init__(evaluator)
Computes the R^2 for the top models in the results dictionary. NOT IMPLEMENTED YET, CURRENTLY YOU GET RMSE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluator
|
SR_evaluator
|
The evaluator used to evaluate the models (e.g., evaluator defined with test set data). This evaluator must be initialized with ranking_function = "rmse". If you're also using the RMSE augmenter, they the same one can be used for both. |
required |
Raises:
| Type | Description |
|---|---|
Exception
|
If the evaluator is not initialized with ranking_function = "rmse" or if y in the evaluator is None. |
Source code in SRToolkit/evaluation/result_augmentation.py
augment_results(results, models, evaluator)
Computes the R^2 for the top models in the results dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
dict
|
The dictionary containing the results to augment. |
required |
models
|
List[dict]
|
The list of models that were evaluated. Variable models[i]["expr"] contains the expression model i, ... |
required |
evaluator
|
SR_evaluator
|
The evaluator used to evaluate the models. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The augmented results dictionary. The results dictionary contains an additional key "best_expr_r^2" with the |
dict
|
R^2 of the best expression, and keys "r^2" and "parameters_r^2" for each of the top_models inside the |
dict
|
results["top_models"] list. |