Skip to content

Commit

Permalink
replace map with mapv_into
Browse files Browse the repository at this point in the history
  • Loading branch information
cospectrum committed May 10, 2024
1 parent 74b7865 commit 4df156f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/metrics_regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ pub trait SingleTargetRegression<F: Float, T: AsSingleTargets<Elem = F>>:
let max_error = self
.as_single_targets()
.sub(&compare_to.as_single_targets())
.iter()
.map(|x| x.abs())
.mapv_into(|x| x.abs())
.into_iter()
.fold(F::neg_infinity(), F::max);
Ok(max_error)
}
/// Mean error between two continuous variables
fn mean_absolute_error(&self, compare_to: &T) -> Result<F> {
self.as_single_targets()
.sub(&compare_to.as_single_targets())
.mapv(|x| x.abs())
.mapv_into(|x| x.abs())
.mean()
.ok_or(Error::NotEnoughSamples)
}
Expand All @@ -41,7 +41,7 @@ pub trait SingleTargetRegression<F: Float, T: AsSingleTargets<Elem = F>>:
fn mean_squared_error(&self, compare_to: &T) -> Result<F> {
self.as_single_targets()
.sub(&compare_to.as_single_targets())
.mapv(|x| x * x)
.mapv_into(|x| x * x)
.mean()
.ok_or(Error::NotEnoughSamples)
}
Expand Down

0 comments on commit 4df156f

Please sign in to comment.