Skip to content

Plotting a a condense tree result using the hdbscan.plots.CondensedTree class #25

Description

@u3ks

Hi all,

Im trying to plot the output of fast_hdbscan.cluster_trees.condense_tree using the hdbscan.plots.CondensedTree class .
I tried converting the result like so:

ct_raw = np.rec.fromarrays((ct[0], ct[1], ct[2], ct[3]), dtype=[(' parent', np.intp),('child', np.intp),('lambda_val', float),('child_size', np.intp)])

Then passing it to the constructor - CondensedTree(ct_raw) - but i get an error that there are some parent nodes without children in the ct_raw array.

Specifically, the .max() call below (from the hdbscan.plots.CondensedTree.get_plot_data) throws the exception that its being called on an empty array:

`
for c in range(last_leaf, root - 1, -1):

        cluster_bounds[c] = [0, 0, 0, 0]

        c_children = self._raw_tree[self._raw_tree['parent'] == c]
        current_size = np.sum(c_children['child_size'])
        current_lambda = cluster_y_coords[c]
        cluster_max_size = current_size
        cluster_max_lambda = c_children['lambda_val'].max()`

Do you have any pointers how to convert between the two representations or how to change the get_plot_data function?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions