Menu

Deep learning for NeuroImaging in Python.

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the gallery for the big picture.

nidl.metrics.regression.regression_report(y_true, y_pred, *, target_names=None, sample_weight=None, digits=2, output_dict=False)[source]

Build a text report showing the main regression metrics.

Parameters:

y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)

Ground truth (correct) target values.

y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)

Estimated targets as returned by a regressor.

target_names : array-like of shape (n_outputs,), default=None

Optional display names by regressor (following index order).

sample_weight : array-like of shape (n_samples,), default=None

Sample weights.

digits : int, default=2

Number of digits for formatting output floating point values. When output_dict is True, this will be ignored and the returned values will not be rounded.

output_dict : bool, default=False

If True, return output as dict.

Returns:

report : str or dict

Text summary of the mean absolute error, median absolute error, root mean squared error, mean squared error, r2 score, pearsonr, and explained variance score for each regressor. The uniform average across all regressors is also computed and reported. Dictionary returned if output_dict is True. Dictionary has the following structure:

{ 'regressor 0': {
    'MAE': 0.5,     # Mean Absolute Error
    'MedAE': 0.5,   # Median Absolute Error
    'RMSE': 0.6,    # Root Mean Squared Error
    'MSE': 0.4,     # Mean Squared Error
    'R2': 0.8,      # R2 score
    'PCC': 0.9,     # Pearson Correlation Coefficient
    'EVar': 0.7,    # Explained Variance score
    },
  'regressor 1': { ... },
   ...
  'average': {
     'MAE': 0.6,
     'MedAE': 0.6,
     'RMSE': 0.7,
     'MSE': 0.5,
     'R2': 0.75,
     'PCC': 0.85,
     'EVar': 0.65
     }
}

The reported average is computed as the arithmetic mean across all regressors. If only one regressor is available, only the ‘regressor 0’ is returned as ‘average’ would result in the same results.

Examples

>>> from nidl.metrics import regression_report
>>> y_true = [[0.1, 1.2], [5.1, 2.0], [2.0, 3.0], [4.0, 2.0]]
>>> y_pred = [[0.0, 0.0], [2.0, 2.0], [1.0, 1.0], [1.0, 1.0]]
>>> print(regression_report(y_true, y_pred))
                MAE   MedAE   RMSE    MSE     R2   PCC  EVar

regressor 0 1.80 2.00 2.21 4.90 -0.34 0.92 0.55 regressor 1 1.05 1.10 1.27 1.61 -2.95 0.44 -0.25

average 1.42 1.55 1.74 3.26 -1.64 0.68 0.15

Follow us

© 2025, nidl developers