bootstrap_statistic#

cinnabar.stats.bootstrap_statistic(y_true: ndarray, y_pred: ndarray, dy_true: ndarray | None = None, dy_pred: ndarray | None = None, ci: float = 0.95, statistic: Literal['RMSE', 'NRMSE', 'MUE', 'RAE', 'R2', 'rho', 'KTAU', 'PI'] = 'RMSE', nbootstrap: int = 1000, include_true_uncertainty: bool = False, include_pred_uncertainty: bool = False) dict[source]#

Compute mean and confidence intervals of specified statistic.

Parameters:
  • y_true (ndarray with shape (N,)) – True values

  • y_pred (ndarray with shape (N,)) – Predicted values

  • dy_true (ndarray with shape (N,) | None, default None) – Errors of true values. If None, the values are assumed to have no errors.

  • dy_pred (ndarray with shape (N,) | None, default None) – Errors of predicted values. If None, the values are assumed to have no errors

  • ci (float, default 0.95) – Interval for confidence interval (CI).

  • statistic ({“RMSE”, “NRMSE”, “MUE”, “RAE”, “R2”, “rho”, “KTAU”, “PI”}, default “RMSE”) – Statistic to be calculated.

  • nbootstrap (int, default 1000) – Number of bootstrap samples used to estimate the confidence interval.

  • include_true_uncertainty (bool, default False) – Whether to account for the uncertainty in y_true when bootstrapping.

  • include_pred_uncertainty (bool, default False) – Whether to account for the uncertainty in y_pred when bootstrapping.

Note

If include_true_uncertainty or include_pred_uncertainty is True, normal noise will be added to the corresponding values during each bootstrap replicate. The standard deviation of the normal noise is taken from dy_true or dy_pred.

Returns:

stats – ‘mle’: statistic computed on the original data ‘mean’ : mean value of the statistic over all bootstrap samples ‘stderr’ : standard error of the statistic over all bootstrap samples ‘low’ : low end of CI ‘high’ : high end of CI

Return type:

dict of float