Optimized MSE
This commit is contained in:
parent
cd47bd7d12
commit
58964ceb41
1 changed files with 1 additions and 3 deletions
|
@ -1,5 +1,3 @@
|
|||
use std::ops::MulAssign;
|
||||
|
||||
use ndarray::{Array1, ArrayView1};
|
||||
|
||||
pub enum Type {
|
||||
|
@ -16,7 +14,7 @@ pub fn parse_type(t: Type) -> (fn(ArrayView1<f64>, ArrayView1<f64>) -> f64, fn(A
|
|||
|
||||
pub fn mse(y_true: ArrayView1<f64>, y_pred: ArrayView1<f64>) -> f64 {
|
||||
let mut temp = &y_true - &y_pred;
|
||||
temp.mul_assign(&temp.clone());
|
||||
temp.mapv_inplace(|x| x * x);
|
||||
let mut sum = 0.0;
|
||||
for i in 0..temp.len() {
|
||||
sum += temp.get(i).unwrap();
|
||||
|
|
Loading…
Reference in a new issue