Skip to content

Commit

Permalink
fix num_events
Browse files Browse the repository at this point in the history
  • Loading branch information
azizkayumov authored and msk committed Dec 5, 2024
1 parent 6aee4bf commit a06d6a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/hdbscan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ fn main() {
);
println!("# of noise events: {}", noise_events.len());
println!(
"# of outliers (prob > 0.9): {}",
outlier_scores.iter().filter(|&&score| score > 0.9).count()
"# of outliers (prob > 0.8): {}",
outlier_scores.iter().filter(|&&score| score > 0.8).count()
);
}

Expand Down
8 changes: 5 additions & 3 deletions src/hdbscan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,13 @@ fn glosh<A: FloatCore>(
min_cluster_size: usize,
) -> Vec<A> {
let deaths = max_lambdas(condensed_mst, min_cluster_size);

// min_parent gives the number of events in the hierarchy
let num_events = condensed_mst
.iter()
.map(|(_, child, _, _)| *child)
.max()
.map_or(0, |max_child| max_child + 1);
.map(|(parent, _, _, _)| *parent)
.min()
.map_or(0, |min_parent| min_parent);

let mut scores = vec![A::zero(); num_events];
for (parent, child, lambda, _) in condensed_mst {
Expand Down

0 comments on commit a06d6a5

Please sign in to comment.