pub fn mean_squared_error<F: Float + Debug>(
predictions: &Array<F, IxDyn>,
targets: &Array<F, IxDyn>,
) -> Result<F>
Expand description
Calculate the mean squared error between predictions and targets
§Arguments
predictions
- Predicted valuestargets
- Target values
§Returns
- The mean squared error
§Examples
use scirs2_neural::utils::mean_squared_error;
use ndarray::arr1;
let predictions = arr1(&[1.0f64, 2.0, 3.0]).into_dyn();
let targets = arr1(&[1.5f64, 1.8, 2.5]).into_dyn();
let mse = mean_squared_error(&predictions, &targets).unwrap();
assert!(mse > 0.0f64);