error_histogram

Function error_histogram 

Source
pub fn error_histogram<F, S1, S2, D1, D2>(
    y_true: &ArrayBase<S1, D1>,
    y_pred: &ArrayBase<S2, D2>,
    n_bins: usize,
) -> Result<ErrorHistogram<F>>
where F: Float + NumCast + Debug + FromPrimitive, S1: Data<Elem = F>, S2: Data<Elem = F>, D1: Dimension, D2: Dimension,
Expand description

Calculates a histogram of error/residual values

§Arguments

  • y_true - Ground truth (correct) target values
  • y_pred - Estimated target values
  • n_bins - Number of bins for the histogram

§Returns

  • An ErrorHistogram struct containing the histogram data

§Examples

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

let y_true = array![3.0, -0.5, 2.0, 7.0, 5.0, 8.0, 1.0, 4.0];
let y_pred = array![2.5, 0.0, 2.0, 8.0, 4.5, 7.5, 1.5, 3.5];

let hist = error_histogram(&y_true, &y_pred, 4).unwrap();
assert_eq!(hist.bin_counts.len(), 4);
assert_eq!(hist.bin_edges.len(), 5);
assert_eq!(hist.n_observations, 8);