Skip to content

Commit

Permalink
fix height
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxHalford committed Oct 5, 2023
1 parent c6d5a1c commit 2f6a989
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ROC AUC appears roughly similar between the Python and Rust implementations. Not
- Using `with_capacity` on each `Vec` in `HST`, as well as the list of HSTs, we gain 1 second. We are now at **~5 seconds**.
- We can't find a nice profiler. So for now we comment code and measure time.
- Storing all attributes in a single array, instead of one array per tree, makes us reach **~3 seconds**.
- We fixed some algorithmic issues. We now reach **~2 seconds** by shear luck.
- We tried using rayon to parallelize over trees, but it didn't bring any improvements.
- We removed the CSV logic from the benchmark, which brings us under **~1 second**.
- There is an opportunity to do the scoring and update logic in one fell swoop. This is because of the nature of online anomaly detection. This would bring us to **~0.6 seconds**. We are not sure if this is a good design choice though, so we may revisit this later.
- We removed the CSV logic from the benchmark, which brings us under **~2.5 second**.
- There is an opportunity to do the scoring and update logic in one fell swoop. This is because of the nature of online anomaly detection. This would bring us to **~0.7 seconds**. We are not sure if this is a good design choice though, so we may revisit this later.
12 changes: 6 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// TODO: padding
// TODO: handle non [0, 1] features
// TODO: weighted sampling of features
// TODO: early stopping in walk

use csv::WriterBuilder;
use light_river::datasets::credit_card::CreditCard;
use light_river::stream::data_stream::{Data, DataStream};
Expand Down Expand Up @@ -35,10 +40,6 @@ struct HST {

impl HST {
fn new(n_trees: u32, height: u32, features: &Vec<String>, rng: &mut ThreadRng) -> Self {
// TODO: padding
// TODO: handle non [0, 1] features
// TODO: weighted sampling of features

// #nodes = 2 ^ height - 1
let n_nodes: usize = usize::try_from(n_trees * (u32::pow(2, height) - 1)).unwrap();
// #branches = 2 ^ (height - 1) - 1
Expand Down Expand Up @@ -83,9 +84,8 @@ fn main() {

let window_size: u32 = 1000;
let mut counter: u32 = 0;
let size_limit = 0.1 * window_size as f32;
let n_trees: u32 = 50;
let height: u32 = 2;
let height: u32 = 6;
let features: Vec<String> = vec![
String::from("V1"),
String::from("V2"),
Expand Down

0 comments on commit 2f6a989

Please sign in to comment.