10000 DOC Update `_hdbscan/_linkage.pyx` with new inline comments by Micky774 · Pull Request #25656 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

DOC Update _hdbscan/_linkage.pyx with new inline comments #25656

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

Closed
wants to merge 1 commit into from

Conversation

Micky774
Copy link
Contributor

Reference Issues/PRs

Follow-up to #24857

What does this implement/fix? Explain your changes.

Improves in-line comments to address algorithm steps directly

Any other comments?

Copy link
Member
@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

I'm always concerned with having inline comments that appear between every line of code. They often describe "what" the code is doing and not "why". In these cases, I prefer to improve the code itself, either by simplifying the code or having better variable names.

min_reachability = np.full(n_samples, fill_value=np.infty, dtype=np.float64)
for i in range(0, n_samples - 1):
# Sub-select nodes not-yet in the tree
Copy link
Member

Choose a reason for hiding this comment

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

Can this be communicate with a better variable name for label_filter?

Comment on lines +70 to 73
# Compute the nodes' current min-reachability scores
left = min_reachability[label_filter]
# Compute the nodes' mutual-reachability to current node
right = mutual_reachability[current_node][current_labels]
Copy link
Member

Choose a reason for hiding this comment

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

left and right are not computing anything. Is there a better name for left and right such that the comment is not required?

Comment on lines +74 to +75
# Update min-reachability, given the new mutual-reachability of all
# nodes from the current node.
Copy link
Member

Choose a reason for hiding this comment

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

Also would a better name for left and right remove the need for this comment?

Copy link
Member
@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

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

LGTM once @thomasjpfan's comments are addressed. Thank you, @Micky774.

Moreover, can you add a TODO to state that mst_from_data_matrix can be backed later by a PairwiseDistancesReduction back-end?

@jjerphan
Copy link
Member
jjerphan commented Mar 9, 2023

Moreover, can you add a TODO to state that mst_from_data_matrix can be backed later by a PairwiseDistancesReduction back-end?

FYI, I have added an item to #22587.

@glemaitre glemaitre deleted the branch scikit-learn:hdbscan July 13, 2023 08:07
@glemaitre glemaitre closed this Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0