plaid.post.metrics

Utility functions for computing and printing metrics for regression problems in PLAID.

Functions

compute_rRMSE_RMSE(→ None)

Compute and print the relative Root Mean Square Error (rRMSE) for scalar outputs.

compute_R2(→ None)

Compute and print the R-squared (R2) score for scalar outputs.

prepare_metrics_for_split(→ float)

Prepare metrics for a specific split and compute the R-squared (R2) score.

pretty_metrics(→ None)

Prints metrics information in a readable format (pretty print).

compute_metrics(→ None)

Compute and save evaluation metrics for a given regression problem.

Module Contents

compute_rRMSE_RMSE(metrics: dict, rel_SE_out_scalars: dict, abs_SE_out_scalars: dict, problem_split: dict, out_scalars_names: list[str]) None[source]

Compute and print the relative Root Mean Square Error (rRMSE) for scalar outputs.

Parameters:
  • metrics (dict) – Dictionary to store the computed metrics.

  • rel_SE_out_scalars (dict) – Dictionary containing relative squared errors for scalar outputs.

  • abs_SE_out_scalars (dict) – Dictionary containing absolute squared errors for scalar outputs.

  • problem_split (dict) – Dictionary specifying how the problem is split.

  • out_scalars_names (list[str]) – List of names of scalar outputs.

compute_R2(metrics: dict, r2_out_scalars: dict, problem_split: dict, out_scalars_names: list[str]) None[source]

Compute and print the R-squared (R2) score for scalar outputs.

Parameters:
  • metrics (dict) – Dictionary to store the computed metrics.

  • r2_out_scalars (dict) – Dictionary containing R2 scores for scalar outputs.

  • problem_split (dict) – Dictionary specifying how the problem is split.

  • out_scalars_names (list[str]) – List of names of scalar outputs.

prepare_metrics_for_split(ref_out_specific_scalars: numpy.ndarray, pred_out_specific_scalars: numpy.ndarray, split_indices: list[int], rel_SE_out_specific_scalars: numpy.ndarray, abs_SE_out_specific_scalars: numpy.ndarray) float[source]

Prepare metrics for a specific split and compute the R-squared (R2) score.

Parameters:
  • ref_out_specific_scalars (np.ndarray) – Array of reference scalar outputs.

  • pred_out_specific_scalars (np.ndarray) – Array of predicted scalar outputs.

  • split_indices (list[int]) – List of indices specifying the split.

  • rel_SE_out_specific_scalars (np.ndarray) – Array to store relative squared errors for scalar outputs.

  • abs_SE_out_specific_scalars (np.ndarray) – Array to store absolute squared errors for scalar outputs.

Returns:

R-squared (R2) score for the specific split.

Return type:

float

pretty_metrics(metrics: dict) None[source]

Prints metrics information in a readable format (pretty print).

Parameters:

metrics (dict) – The metrics dictionary to print.

compute_metrics(ref_dataset: plaid.Dataset | str | pathlib.Path, pred_dataset: plaid.Dataset | str | pathlib.Path, problem: plaid.ProblemDefinition | str | pathlib.Path, save_file_name: str = 'test_metrics', verbose: bool = False) None[source]

Compute and save evaluation metrics for a given regression problem.

Parameters:
  • ref_dataset (Dataset | str | Path) – Reference dataset or path to a reference dataset.

  • pred_dataset (Dataset | str | Path) – Predicted dataset or path to a predicted dataset.

  • problem (ProblemDefinition | str | Path) – Problem definition or path to a problem definition.

  • save_file_name (str, optional) – Name of the file to save the metrics. Defaults to “test_metrics”.

  • verbose (bool, optional) – If True, print detailed information during computation.