normalized_root_mean_squared_error

Function normalized_root_mean_squared_error 

Source
pub fn normalized_root_mean_squared_error<F, S1, S2, D1, D2>(
    y_true: &ArrayBase<S1, D1>,
    y_pred: &ArrayBase<S2, D2>,
    normalization: &str,
) -> Result<F>
where F: Float + NumCast + Debug + SimdUnifiedOps, S1: Data<Elem = F>, S2: Data<Elem = F>, D1: Dimension, D2: Dimension,
Expand description

Calculates the normalized root mean squared error (NRMSE)

§Arguments

  • y_true - Ground truth (correct) target values
  • y_pred - Estimated target values
  • normalization - Method used for normalization:
    • “mean” - RMSE / mean(y_true)
    • “range” - RMSE / (max(y_true) - min(y_true))
    • “iqr” - RMSE / interquartile range of y_true

§Returns

  • The normalized root mean squared error

§Examples

use scirs2_core::ndarray::array;
use scirs2_metrics::regression::normalized_root_mean_squared_error;

let y_true = array![3.0, -0.5, 2.0, 7.0];
let y_pred = array![2.5, 0.0, 2.0, 8.0];

let nrmse_mean: f64 = normalized_root_mean_squared_error(&y_true, &y_pred, "mean").unwrap();
let nrmse_range: f64 = normalized_root_mean_squared_error(&y_true, &y_pred, "range").unwrap();
assert!(nrmse_mean > 0.0);
assert!(nrmse_range > 0.0);