Skip to content

Commit

Permalink
Add max score normalisation
Browse files Browse the repository at this point in the history
  • Loading branch information
AdilZouitine committed Oct 21, 2023
1 parent 7ea3985 commit ee78b8e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/anomaly/half_space_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ impl<F: Float + FromPrimitive + AddAssign + SubAssign + MulAssign + DivAssign> H
}
}
if do_score {
score = F::one() - (score / self.max_score());
return Some(score);
}
return None;

Check warning on line 198 in src/anomaly/half_space_tree.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> src/anomaly/half_space_tree.rs:198:9 | 198 | return None; | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = note: `#[warn(clippy::needless_return)]` on by default help: remove `return` | 198 - return None; 198 + None |
Expand All @@ -202,4 +203,9 @@ impl<F: Float + FromPrimitive + AddAssign + SubAssign + MulAssign + DivAssign> H
pub fn score_one(&mut self, observation: &Observation<F>) -> Option<F> {
self.update(observation, true, false)
}
fn max_score(&self) -> F {
F::from(self.n_trees).unwrap()
* F::from(self.window_size).unwrap()
* (F::from(2.).unwrap().powi(self.height as i32 + 1) - F::one())
}
}

0 comments on commit ee78b8e

Please sign in to comment.