-
Notifications
You must be signed in to change notification settings - Fork 671
[REVIEW] HDBSCAN #3821
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
Merged
Merged
[REVIEW] HDBSCAN #3821
Changes from all commits
Commits
Show all changes
209 commits
Select commit
Hold shift + click to select a range
c0a1b8b
HDBSCAN
cjnolet 3800f76
Fixing style
cjnolet 362d429
Progress
cjnolet abf2267
Checking in
cjnolet c68bd8d
Checking in todo stubs of remaining work for initial implementation
cjnolet 78a8432
Creating output condensed hierarchy
cjnolet b502e1d
Resizing rmm arrays
cjnolet 146ac00
Adding missing semicolon
cjnolet 3cee98b
initial ideas to compute stabilities
divyegala 60253ce
Checking in
cjnolet e4668d3
Updating
cjnolet 1e9f557
separating kernels into detail
divyegala 0331697
Merge branch 'fea-020-hdbscan' of github.com:cjnolet/cuml into fea-02…
divyegala fd77b48
allocating stabilities through caller
divyegala 7edb4a3
cleaning stabilities a bit
divyegala 0efd58b
Initial stub for eom is done.
cjnolet bbb35db
Adding data to epilogue
cjnolet 83d8ac3
COuple small updates
cjnolet f563aca
Adding get_stability scores
cjnolet bbe1ffe
tests building
divyegala d135645
cleaning up some comments
cjnolet 0fce1bb
Fixing style
cjnolet 7052836
merging
divyegala b6048ce
merge and compile
divyegala f05d545
Updates to get hdbscan to compile
cjnolet 1628a36
Getting remaining stuff in extract_clusters to compile
cjnolet 463f757
Using zip iterators for copy_if
cjnolet dcc83db
compiling compute stabilities
divyegala 4829b21
stabilities and merge building
divyegala 8814181
Sorry!
cjnolet 025c5d4
Renaming and moving a few things around
cjnolet 5335252
Debugging mutual reachability through gtest
cjnolet 2844a11
Mutual reachability and dendrogram re-labeling executes
cjnolet d4dfc07
Fixing style
cjnolet c8c9e55
Condensed hierarchy executes without error. Output needs to be verifi…
cjnolet 5619959
Fixing formatting
cjnolet 624fdb0
Some light prints show the condensing is at least performing the bfs.
cjnolet de4569c
Fixing style
cjnolet 6cc8d74
condensed clusters
cjnolet 4865e64
Some updates. Fixing off by 1 error
cjnolet aa87e5b
correcting stabilities calculation
divyegala 1532e2a
Adding gtest for condensing
cjnolet 88716d3
Pushing
cjnolet 269d828
condensing *should* be correct
cjnolet de0c7b3
Cleaning up cluster condensing. Should be mostly correct
cjnolet 741df66
more updates
divyegala 52563df
Merge branch 'fea-020-hdbscan' of github.com:cjnolet/cuml into fea-02…
divyegala 5095f9f
Filling in union find & host-based labeling
cjnolet c389a7a
Fixing style
cjnolet 0b5d3e7
monotonic parent child and stabilities running
divyegala 071b899
merge
divyegala 13c8672
Adding gtest for eom
cjnolet 1cc4dbf
Adding gtest for eom
cjnolet 2f17cf8
updated rmm, so removed ->on(stream)
divyegala a9d1058
working stabilities gtest
divyegala 68a9344
Adding iris to cluster condensing tests
cjnolet c3dbd8c
Code path through stabilities, eom, and labeling seems to work.
cjnolet 89deff8
Merge branch 'branch-0.20' into fea-020-hdbscan
cjnolet b143a55
Fixing reachability
cjnolet dcd590c
Adding support for max_cluster_size
cjnolet 699183d
Making labels monotonic
cjnolet e78b48a
sketching probabilities
divyegala b6a85ef
Merge branch 'fea-020-hdbscan' of github.com:cjnolet/cuml into fea-02…
divyegala ea759ef
passing probabilities gtest
divyegala 0818d10
fixing compute-sanitizer issue in excess of mass
cjnolet 998c8d4
Cleaning up API for inputs and outputs
cjnolet fb67441
Fixing memory error
cjnolet e000f41
cluster epsilon search start
divyegala f41330a
C++ changes for python wrapper
cjnolet 3bb021e
Addiing hdbscan python wrapper and empty classes to aid in plotting.
cjnolet ebfa61d
C++ changes for python wrapper
cjnolet ce9f809
Merge branch 'fea-020-hdbscan' into fea-020-hdbscan_py
cjnolet 21c39ae
C++ changes
cjnolet 9088549
Cython changes
cjnolet 069b1b5
C++ changes
cjnolet f26ca59
Merge branch 'fea-020-hdbscan' into fea-020-hdbscan_py
cjnolet 2f624ef
Using rmm allocator directly in thrust for now
cjnolet 38734d6
Using rmm allocator directly in thrust for now
cjnolet 1f7c9ad
Merge branch 'fea-020-hdbscan' into fea-020-hdbscan_py
cjnolet 4a5b426
Fixing python style
cjnolet 90d7de6
Fixing cpp style
cjnolet 8d560a4
Merge branch 'fea-020-hdbscan' into fea-020-hdbscan_py
cjnolet 8408c78
merge
divyegala babf10b
Merge branch 'fea-020-hdbscan' of github.com:cjnolet/cuml into fea-02…
divyegala ee3c07b
introducing cluster tree creation
divyegala 5f11ea3
correcting eom test with cluster tree
divyegala 3694173
Adding labeling for robust single linkage (and dbscan)
cjnolet f6cb0b5
Merge branch 'fea-020-hdbscan' into fea-020-hdbscan_py
cjnolet 8266f3c
stubbing out robust single linkage
cjnolet 7332199
Small changes to support robust single linkage
cjnolet a4b560c
cluster selection travel upwards working
divyegala 6a6a9df
separating bfs out
divyegala 93c106c
added cluster negation to epsilon search
divyegala ee90094
merge
divyegala b7d67dd
style check
divyegala bec62e7
Separating extract into smaller files.
cjnolet e063a68
styl
cjnolet 01c9904
Merge branch 'fea-020-hdbscan' into fea-020-hdbscan_py
cjnolet 7b57cd0
leaf selection method
divyegala 0ef2b86
Cleaning up prints for hdbscan and fixing small segfault
cjnolet e9a6a4e
Updates to python
cjnolet 5e7b850
Cleaning up prints for hdbscan and fixing small segfault
cjnolet 4f45468
Testing updates
cjnolet 3ae88eb
Checking in
cjnolet 5ac0a8f
merging hdbscan cpp
divyegala affeb86
Merge branch 'fea-020-hdbscan_py' of github.com:cjnolet/cuml into fea…
divyegala 00b0b39
Working through debugging
cjnolet a0caa05
Working through debugging
cjnolet 8ff536b
Fixign swapped args
cjnolet acd4c5a
Updates to pytest
cjnolet c097722
C++ changes
cjnolet 1b7a638
Adding debugging info
cjnolet 150b76e
Updates to C++
cjnolet 1d94a6a
Python / cython updates
cjnolet afe8c60
C++ updates for debugging
cjnolet 433afe9
Python updates
cjnolet 6e6b2d7
fixing stabilities computation for root
divyegala cbfc359
Merge branch 'fea-020-hdbscan_py' of github.com:cjnolet/cuml into fea…
divyegala 4e4f93e
make monotonic filter noise
divyegala c7fdaf4
C++ changes
cjnolet 8fa37a8
Python changes
cjnolet c9717b3
sorting condensed parents and children
divyegala 9032027
merge
divyegala a153abd
Flipiing
cjnolet d63bb72
+ changes
cjnolet d35db43
pytthon changes
cjnolet baffb8b
C++ updates
cjnolet 70c18ed
Python updates
cjnolet 8efd3f2
Properly propagating lambda during cluster condensing so noise points…
cjnolet 463f76f
Python updates
cjnolet f969ee8
Removing prints
cjnolet 342f805
Adding different hyperparams to pytests for easier debugging.
cjnolet c999ecd
Adding additional hyperparams to pytest
cjnolet 13b5314
Adding allow single cluster to params
cjnolet 4b4e47e
C++ changes
cjnolet 518cb79
Updates to unify logic for RSL and HDBSCAN. Added pytest for common c…
cjnolet c1eb5ff
C++ updates, fixing root cluster case. Leaf selection method fixes
cjnolet a20e13f
Correspoding pytest updates
cjnolet 584487d
Debugging info
cjnolet 1f20381
Updating python test
cjnolet addc71e
Verified excess of mass
cjnolet ef4c3af
Updating tests.
cjnolet 4f2f99b
debugging through stabilities
divyegala 9b4bd9d
pytest updates
cjnolet b93870a
pytest updates
cjnolet 6c4977d
Adding mst generated from reference impl to condensing gtest
cjnolet 46ca653
Adding c++ gtest
cjnolet b3457c5
Updates to pytest
cjnolet daae422
Querying for additional points for mutual reachability
cjnolet 414788c
Updates to pytest to over-query knn graph for mutual reachability
cjnolet 29000f2
testing through mst and knn
divyegala 9d6daf2
Updates to pytests
cjnolet acba5e8
Removing knn print
cjnolet 8fce905
Adding condensed tree for plotting
cjnolet 372ccc5
Plotting min span tree and dendrogram
cjnolet d556d47
Pulling plots fom tests
cjnolet 8beee00
merge
divyegala 98800dc
Moving HDBSCAN and robust single linkage to experimental
cjnolet d8f1c19
Checking in cpp stuff
cjnolet a531ae1
Checkking in pytest
cjnolet 0e4fb0b
New knn is running but neighborhoods are not yet completely correct
cjnolet 915d34d
Pytest
cjnolet 2b3d229
C++ changes
cjnolet 5964cab
pytest changes
cjnolet 0ac5b69
intermediate merge
divyegala 69a48aa
more merge
divyegala 9d181e1
testing leaf method
divyegala d14dd38
c++ updates
cjnolet 27f4c7b
Python updates
cjnolet 4da0fe6
Updates to c++
cjnolet cca3222
Style updates (c++)
cjnolet 7fdad14
Supporting n_clusters =1. Adding test
cjnolet f1caec2
Fixing python style
cjnolet cf835fe
Merge branch 'branch-0.20' into fea-020-hdbscan_py
cjnolet 3ba064c
Cleaining up debug prints
cjnolet e1f8bb1
Copyright checkjer
cjnolet 76b392e
debuging epsilong search
divyegala 7b2c082
testing all parameters epsilon
divyegala 166dc04
Adding doxygen docs
cjnolet 0cd10c8
Fixing build errors
cjnolet 64e3475
no need to sort for probabilities since condensed hierarchy is sorted…
divyegala a475062
separating kernels out
divyegala 8db6d14
Fixing pytest for hdbscan
cjnolet 4f72996
Updates to cython
cjnolet e4a0139
Using sizeof and renaming stabilities to clustr_persistence
cjnolet 1da875d
refactor gtests and get assertions running
divyegala 0dfb9d1
Merge branch 'fea-020-hdbscan_py' of github.com:cjnolet/cuml into fea…
divyegala 2ad39bc
cluster selection epsilon for eom gtest
divyegala 8e302db
style check
divyegala 6fc604f
allow_single_cluster=True gtest for eom
divyegala b1f551b
finalizing hdbscan gtests
divyegala 54b8c10
digits end-to-end gtest
divyegala a6ac3e7
Review feedback so far
cjnolet 70d19f3
Removing robust single linkage for 21.06. Will add in a future release
cjnolet fe55fb9
Review updates
cjnolet 5e5d99f
review feedback
divyegala 9bdcbf6
Merge branch 'fea-020-hdbscan_py' of github.com:cjnolet/cuml into fea…
divyegala 804bc9c
more review comments
divyegala e94d54d
merge upstream
divyegala 03ce6d3
remove cudaMalloc from cub function
divyegala 85b2282
Final review items
cjnolet 9c38782
not running cluster condensing gtest
divyegala af28c9f
Merge branch 'branch-21.06' of github.com:rapidsai/cuml into fea-020-…
divyegala 6769356
Updates based on final review items.
cjnolet d143f05
Adding hdbscan to build dependencies (for pytests)
cjnolet 13dca59
Removing hdbscan change from HDBSCAN PR
cjnolet 095dcea
Fixing docs and addig param
cjnolet 444cffb
Fixing base test
cjnolet 1519478
Fixing doxygen
cjnolet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,314 @@ | ||
| /* | ||
| * Copyright (c) 2021, NVIDIA CORPORATION. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <raft/linalg/distance_type.h> | ||
| #include <raft/handle.hpp> | ||
|
|
||
| #include <rmm/device_uvector.hpp> | ||
|
|
||
| #include <cstddef> | ||
|
|
||
| namespace ML { | ||
| namespace HDBSCAN { | ||
| namespace Common { | ||
|
|
||
| /** | ||
| * The Condensed hierarchicy is represented by an edge list with | ||
| * parents as the source vertices, children as the destination, | ||
| * with attributes for the cluster size and lambda value. | ||
| * | ||
| * @tparam value_idx | ||
| * @tparam value_t | ||
| */ | ||
| template <typename value_idx, typename value_t> | ||
| class CondensedHierarchy { | ||
| public: | ||
| /** | ||
| * Constructs an empty condensed hierarchy object which requires | ||
| * condense() to be called in order to populate the state. | ||
| * @param handle_ | ||
| * @param n_leaves_ | ||
| */ | ||
| CondensedHierarchy(const raft::handle_t &handle_, size_t n_leaves_); | ||
|
|
||
| /** | ||
| * Constructs a condensed hierarchy object with existing arrays | ||
| * which already contain a condensed hierarchy. | ||
| * @param handle_ | ||
| * @param n_leaves_ | ||
| * @param n_edges_ | ||
| * @param parents_ | ||
| * @param children_ | ||
| * @param lambdas_ | ||
| * @param sizes_ | ||
| */ | ||
| CondensedHierarchy(const raft::handle_t &handle_, size_t n_leaves_, | ||
| int n_edges_, value_idx *parents_, value_idx *children_, | ||
| value_t *lambdas_, value_idx *sizes_); | ||
|
|
||
| /** | ||
| * Constructs a condensed hierarchy object by moving | ||
| * rmm::device_uvector. Used to construct cluster trees | ||
| * @param handle_ | ||
| * @param n_leaves_ | ||
| * @param n_edges_ | ||
| * @param n_clusters_ | ||
| * @param parents_ | ||
| * @param children_ | ||
| * @param lambdas_ | ||
| * @param sizes_ | ||
| */ | ||
| CondensedHierarchy(const raft::handle_t &handle_, size_t n_leaves_, | ||
| int n_edges_, int n_clusters_, | ||
| rmm::device_uvector<value_idx> &&parents_, | ||
| rmm::device_uvector<value_idx> &&children_, | ||
| rmm::device_uvector<value_t> &&lambdas_, | ||
| rmm::device_uvector<value_idx> &&sizes_); | ||
| /** | ||
| * To maintain a high level of parallelism, the output from | ||
| * Condense::build_condensed_hierarchy() is sparse (the cluster | ||
| * nodes inside any collapsed subtrees will be 0). | ||
| * | ||
| * This function converts the sparse form to a dense form and renumbers | ||
| * the cluster nodes into a topological sort order. The renumbering | ||
| * reverses the values in the parent array since root has the largest value | ||
| * in the single-linkage tree. Then, it makes the combined parent and | ||
| * children arrays monotonic. Finally all of the arrays of the dendrogram | ||
| * are sorted by parent->children->sizes (e.g. topological). The root node | ||
| * will always have an id of 0 and the largest cluster size. | ||
| * | ||
| * Ths single-linkage tree dendrogram is a binary tree and parents/children | ||
| * can be found with simple indexing arithmetic but the condensed tree no | ||
| * longer has this property and so the tree now relies on either | ||
| * special indexing or the topological ordering for efficient traversal. | ||
| */ | ||
| void condense(value_idx *full_parents, value_idx *full_children, | ||
| value_t *full_lambdas, value_idx *full_sizes, | ||
| value_idx size = -1); | ||
|
|
||
| value_idx get_cluster_tree_edges(); | ||
|
|
||
| value_idx *get_parents() { return parents.data(); } | ||
| value_idx *get_children() { return children.data(); } | ||
| value_t *get_lambdas() { return lambdas.data(); } | ||
| value_idx *get_sizes() { return sizes.data(); } | ||
| value_idx get_n_edges() { return n_edges; } | ||
| int get_n_clusters() { return n_clusters; } | ||
| value_idx get_n_leaves() const { return n_leaves; } | ||
|
|
||
| private: | ||
| const raft::handle_t &handle; | ||
|
|
||
| rmm::device_uvector<value_idx> parents; | ||
| rmm::device_uvector<value_idx> children; | ||
| rmm::device_uvector<value_t> lambdas; | ||
| rmm::device_uvector<value_idx> sizes; | ||
|
|
||
| size_t n_edges; | ||
| size_t n_leaves; | ||
| int n_clusters; | ||
| value_idx root_cluster; | ||
| }; | ||
|
|
||
| enum CLUSTER_SELECTION_METHOD { EOM = 0, LEAF = 1 }; | ||
|
|
||
| class RobustSingleLinkageParams { | ||
| public: | ||
| int k = 5; | ||
| int min_samples = 5; | ||
| int min_cluster_size = 5; | ||
| int max_cluster_size = 0; | ||
|
|
||
| float cluster_selection_epsilon = 0.0; | ||
|
|
||
| bool allow_single_cluster = false; | ||
|
|
||
| float alpha = 1.0; | ||
| }; | ||
|
|
||
| class HDBSCANParams : public RobustSingleLinkageParams { | ||
| public: | ||
| CLUSTER_SELECTION_METHOD cluster_selection_method = | ||
| CLUSTER_SELECTION_METHOD::EOM; | ||
| }; | ||
|
|
||
| /** | ||
| * Container object for output information common between | ||
| * robust single linkage variants. | ||
| * @tparam value_idx | ||
| * @tparam value_t | ||
| */ | ||
| template <typename value_idx, typename value_t> | ||
| class robust_single_linkage_output { | ||
|
cjnolet marked this conversation as resolved.
|
||
| public: | ||
| /** | ||
| * Construct output object with empty device arrays of | ||
| * known size. | ||
| * @param handle_ raft handle for ordering cuda operations | ||
| * @param n_leaves_ number of data points | ||
| * @param labels_ labels array on device (size n_leaves) | ||
| * @param children_ dendrogram src/dst array (size n_leaves - 1, 2) | ||
| * @param sizes_ dendrogram cluster sizes array (size n_leaves - 1) | ||
| * @param deltas_ dendrogram distances array (size n_leaves - 1) | ||
| * @param mst_src_ min spanning tree source array (size n_leaves - 1) | ||
| * @param mst_dst_ min spanning tree destination array (size n_leaves - 1) | ||
| * @param mst_weights_ min spanninng tree distances array (size n_leaves - 1) | ||
| */ | ||
| robust_single_linkage_output(const raft::handle_t &handle_, int n_leaves_, | ||
| value_idx *labels_, value_idx *children_, | ||
| value_idx *sizes_, value_t *deltas_, | ||
| value_idx *mst_src_, value_idx *mst_dst_, | ||
| value_t *mst_weights_) | ||
| : handle(handle_), | ||
| n_leaves(n_leaves_), | ||
| n_clusters(0), | ||
| labels(labels_), | ||
| children(children_), | ||
| sizes(sizes_), | ||
| deltas(deltas_), | ||
| mst_src(mst_src_), | ||
| mst_dst(mst_dst_), | ||
| mst_weights(mst_weights_) {} | ||
|
|
||
| int get_n_leaves() const { return n_leaves; } | ||
| int get_n_clusters() const { return n_clusters; } | ||
| value_idx *get_labels() { return labels; } | ||
| value_idx *get_children() { return children; } | ||
| value_idx *get_sizes() { return sizes; } | ||
| value_t *get_deltas() { return deltas; } | ||
| value_idx *get_mst_src() { return mst_src; } | ||
| value_idx *get_mst_dst() { return mst_dst; } | ||
| value_t *get_mst_weights() { return mst_weights; } | ||
|
|
||
| /** | ||
| * The number of clusters is set by the algorithm once it is known. | ||
| * @param n_clusters_ number of resulting clusters | ||
| */ | ||
| void set_n_clusters(int n_clusters_) { n_clusters = n_clusters_; } | ||
|
|
||
| protected: | ||
| const raft::handle_t &get_handle() { return handle; } | ||
|
|
||
| const raft::handle_t &handle; | ||
|
|
||
| int n_leaves; | ||
| int n_clusters; | ||
|
|
||
| value_idx *labels; // size n_leaves | ||
|
|
||
| // Dendrogram | ||
| value_idx *children; // size n_leaves * 2 | ||
| value_idx *sizes; // size n_leaves | ||
| value_t *deltas; // size n_leaves | ||
|
|
||
| // MST (size n_leaves - 1). | ||
| value_idx *mst_src; | ||
| value_idx *mst_dst; | ||
| value_t *mst_weights; | ||
| }; | ||
|
|
||
| /** | ||
| * Plain old container object to consolidate output | ||
| * arrays. This object is intentionally kept simple | ||
| * and straightforward in order to ease its use | ||
| * in the Python layer. For this reason, the MST | ||
| * arrays and renumbered dendrogram array, as well | ||
| * as its aggregated distances/cluster sizes, are | ||
| * kept separate. The condensed hierarchy is computed | ||
| * and populated in a separate object because its size | ||
| * is not known ahead of time. An RMM device vector is | ||
| * held privately and stabilities initialized explicitly | ||
| * since that size is also not known ahead of time. | ||
| * @tparam value_idx | ||
| * @tparam value_t | ||
| */ | ||
| template <typename value_idx, typename value_t> | ||
| class hdbscan_output : public robust_single_linkage_output<value_idx, value_t> { | ||
| public: | ||
| hdbscan_output(const raft::handle_t &handle_, int n_leaves_, | ||
| value_idx *labels_, value_t *probabilities_, | ||
| value_idx *children_, value_idx *sizes_, value_t *deltas_, | ||
| value_idx *mst_src_, value_idx *mst_dst_, | ||
| value_t *mst_weights_) | ||
| : robust_single_linkage_output<value_idx, value_t>( | ||
| handle_, n_leaves_, labels_, children_, sizes_, deltas_, mst_src_, | ||
| mst_dst_, mst_weights_), | ||
| probabilities(probabilities_), | ||
| stabilities(0, handle_.get_stream()), | ||
| condensed_tree(handle_, n_leaves_) {} | ||
|
|
||
| // Using getters here, making the members private and forcing | ||
| // consistent state with the constructor. This should make | ||
| // it much easier to use / debug. | ||
| value_t *get_probabilities() { return probabilities; } | ||
| value_t *get_stabilities() { | ||
| ASSERT(stabilities.size() > 0, "stabilities needs to be initialized"); | ||
| return stabilities.data(); | ||
| } | ||
|
|
||
| /** | ||
| * Once n_clusters is known, the stabilities array | ||
| * can be initialized. | ||
| * @param n_clusters_ | ||
| */ | ||
| void set_n_clusters(int n_clusters_) { | ||
| robust_single_linkage_output<value_idx, value_t>::set_n_clusters( | ||
| n_clusters_); | ||
| stabilities.resize( | ||
| n_clusters_, | ||
| robust_single_linkage_output<value_idx, value_t>::get_handle() | ||
| .get_stream()); | ||
| } | ||
|
|
||
| CondensedHierarchy<value_idx, value_t> &get_condensed_tree() { | ||
| return condensed_tree; | ||
| } | ||
|
|
||
| private: | ||
| value_t *probabilities; // size n_leaves | ||
|
|
||
| // Size not known ahead of time. Initialize | ||
| // with `initialize_stabilities()` method. | ||
| rmm::device_uvector<value_t> stabilities; | ||
|
|
||
| // Use condensed hierarchy to wrap | ||
| // condensed tree outputs since we do not | ||
| // know the size ahead of time. | ||
| CondensedHierarchy<value_idx, value_t> condensed_tree; | ||
| }; | ||
|
|
||
| template class CondensedHierarchy<int, float>; | ||
|
|
||
| }; // namespace Common | ||
| }; // namespace HDBSCAN | ||
|
|
||
| /** | ||
| * Executes HDBSCAN clustering on an mxn-dimensional input array, X. | ||
| * @param[in] handle raft handle for resource reuse | ||
| * @param[in] X array (size m, n) on device in row-major format | ||
| * @param m number of rows in X | ||
| * @param n number of columns in X | ||
| * @param metric distance metric to use | ||
| * @param params struct of configuration hyper-parameters | ||
| * @param out struct of output data and arrays on device | ||
| */ | ||
| void hdbscan(const raft::handle_t &handle, const float *X, size_t m, size_t n, | ||
|
cjnolet marked this conversation as resolved.
|
||
| raft::distance::DistanceType metric, | ||
| HDBSCAN::Common::HDBSCANParams ¶ms, | ||
| HDBSCAN::Common::hdbscan_output<int, float> &out); | ||
| } // END namespace ML | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.