Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example usage for outlier scores #82

Merged
merged 3 commits into from
Dec 5, 2024
Merged

Example usage for outlier scores #82

merged 3 commits into from
Dec 5, 2024

Conversation

azizkayumov
Copy link
Contributor

@azizkayumov azizkayumov commented Dec 5, 2024

Closes #80

Summary by CodeRabbit

  • New Features

    • Enhanced output for clustering results, now reporting "noise events" and providing additional insights on outliers.
  • Bug Fixes

    • Corrected a typographical error in an error message related to the stability dictionary.
  • Documentation

    • Updated comments for clarity on definitions and formulas in the clustering implementation.

Copy link

coderabbitai bot commented Dec 5, 2024

Walkthrough

The changes in this pull request primarily involve renaming variables in the clustering functionality of the examples/hdbscan.rs file to enhance clarity, specifically changing outliers to noise_events and _outlier_scores to outlier_scores. The output statements have been updated to reflect these new names, including a new print statement for outliers with a probability greater than 0.8. Additionally, the src/hdbscan.rs file has been modified to correct a typo and clarify comments, improving code readability without altering functionality.

Changes

File Change Summary
examples/hdbscan.rs Renamed variables: outliers to noise_events, _outlier_scores to outlier_scores. Updated print statements to reflect new variable names and added output for outliers with probability > 0.8.
src/hdbscan.rs Corrected typo in error message from "corruptted" to "corrupted". Updated comments for clarity and renamed largest_parent to largest_cluster_id.

Assessment against linked issues

Objective Addressed Explanation
Print average outlier score of noise points (#80) No implementation for printing the average outlier score was included.

Possibly related PRs

  • Outlier scores for HDBSCAN #73: Modifications to the fit method in the HDbscan struct, which relate to the output of outlier scores and align with the changes made in this PR.

Poem

🐇 In the land of clusters, where data does play,
Noise events frolic, outliers at bay.
With clearer names now, the code shines bright,
A typo corrected, everything feels right!
Let's print those scores, let the insights flow,
In the garden of data, watch our knowledge grow! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4dd222c and 3d8daed.

📒 Files selected for processing (2)
  • examples/hdbscan.rs (2 hunks)
  • src/hdbscan.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/hdbscan.rs
🔇 Additional comments (3)
src/hdbscan.rs (3)

369-369: LGTM: Fixed typo in error message

The correction from "corruptted" to "corrupted" improves the error message clarity.


451-452: LGTM: Improved accuracy of GLOSH algorithm documentation

The comment updates correctly reflect that lambda_A corresponds to eps_A, which aligns with the mathematical formulation in the referenced paper (https://dl.acm.org/doi/10.1145/2733381).


487-491: LGTM: Improved variable naming for better clarity

The renaming from largest_parent to largest_cluster_id better reflects the variable's purpose and improves code readability. All references are consistently updated.

Also applies to: 495-496


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
examples/hdbscan.rs (2)

44-44: LGTM! Consider adding a comment about the score interpretation.

The variable renaming improves clarity by distinguishing between noise events and their outlier scores. Since the PR focuses on demonstrating outlier score usage, consider adding a comment explaining that these scores can be interpreted as probabilities in the range [0, 1).

-    let (clusters, noise_events, outlier_scores) = clustering.fit(&data.view());
+    // clusters: HashMap of cluster labels to point indices
+    // noise_events: Vector of indices for points not assigned to any cluster
+    // outlier_scores: Vector of scores in [0, 1) indicating the probability of each point being an outlier
+    let (clusters, noise_events, outlier_scores) = clustering.fit(&data.view());

53-57: LGTM! Consider enhancing the outlier statistics.

The new output effectively demonstrates the practical use of outlier scores. To provide even more insight, consider adding:

  1. The average outlier score for noise events (as mentioned in the PR description)
  2. A configurable threshold instead of the hardcoded 0.9
     println!("# of noise events: {}", noise_events.len());
+    if !noise_events.is_empty() {
+        let avg_noise_score: f64 = noise_events
+            .iter()
+            .map(|&idx| outlier_scores[idx])
+            .sum::<f64>()
+            / noise_events.len() as f64;
+        println!("Average outlier score for noise events: {:.3}", avg_noise_score);
+    }
+    const OUTLIER_THRESHOLD: f64 = 0.9;
     println!(
-        "# of outliers (prob > 0.9): {}",
-        outlier_scores.iter().filter(|&&score| score > 0.9).count()
+        "# of outliers (prob > {}): {}",
+        OUTLIER_THRESHOLD,
+        outlier_scores.iter().filter(|&&score| score > OUTLIER_THRESHOLD).count()
     );
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 33a6712 and 4dd222c.

📒 Files selected for processing (2)
  • examples/hdbscan.rs (2 hunks)
  • src/hdbscan.rs (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/hdbscan.rs

@msk msk merged commit a06d6a5 into petabi:main Dec 5, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add example usage for outlier scores
2 participants