# ML Namespace

#### WARNING
Primarily internal API: it may change or disappear without notice and has no
stability, deprecation, backward-compatibility, or input-validation
guarantees. Callers must validate inputs and satisfy all memory, stream, and
lifetime preconditions. Prefer the supported [Python API](../../../../api/index.html.md).

### namespace ML

### Typedefs

### using cuda_launch_t = unsigned int

Integer type expected by CUDA launch configuration (`dim3` components, shared-mem size, etc.). 

Prefer `[ML::narrow_cast](#namespaceML_1acb2938e9f8fafebff42d3942829e41f8)<[ML::cuda_launch_t](#namespaceML_1a8650d95d72f2de4a32434f8466daac7f)>(...)` over a bare `[narrow_cast](#namespaceML_1acb2938e9f8fafebff42d3942829e41f8)<unsigned int>(...)` when the value is destined for a `<<<>>>` grid/block dimension. This keeps call sites self-documenting and lets us adapt to future CUDA API changes in one place. 

### using solver = raft::linalg::solver

### using mg_solver = raft::linalg::solver

### typedef [paramsTSVDTemplate](#_CPPv4I0EN2ML18paramsTSVDTemplateE) paramsTSVD

### typedef [paramsPCATemplate](#_CPPv4I0EN2ML17paramsPCATemplateE) paramsPCA

### typedef [paramsPCATemplate](#_CPPv4I0EN2ML17paramsPCATemplateE)<[mg_solver](#_CPPv4N2ML9mg_solverE)> paramsPCAMG

### typedef [paramsTSVDTemplate](#_CPPv4I0EN2ML18paramsTSVDTemplateE)<[mg_solver](#_CPPv4N2ML9mg_solverE)> paramsTSVDMG

### typedef [IsolationForestModel](#_CPPv4I0EN2ML20IsolationForestModelE)<float> IsolationForestF

### typedef [IsolationForestModel](#_CPPv4I0EN2ML20IsolationForestModelE)<double> IsolationForestD

### typedef [RandomForestMetaData](#_CPPv4I00EN2ML20RandomForestMetaDataE)<float, int> RandomForestClassifierF

### typedef [RandomForestMetaData](#_CPPv4I00EN2ML20RandomForestMetaDataE)<double, int> RandomForestClassifierD

### typedef [RandomForestMetaData](#_CPPv4I00EN2ML20RandomForestMetaDataE)<float, float> RandomForestRegressorF

### typedef [RandomForestMetaData](#_CPPv4I00EN2ML20RandomForestMetaDataE)<double, double> RandomForestRegressorD

### typedef int64_t knn_indices_dense_t

### typedef int knn_indices_sparse_t

### Enums

### enum RF_type

*Values:*

### enumerator CLASSIFICATION

### enumerator REGRESSION

### enum task_category

*Values:*

### enumerator REGRESSION_MODEL

### enumerator CLASSIFICATION_MODEL

### enum TSNE_ALGORITHM

*Values:*

### enumerator EXACT

### enumerator BARNES_HUT

### enumerator FFT

### enum TSNE_INIT

*Values:*

### enumerator RANDOM

### enum lr_type

*Values:*

### enumerator OPTIMAL

### enumerator CONSTANT

### enumerator INVSCALING

### enumerator ADAPTIVE

### enum loss_funct

*Values:*

### enumerator SQRD_LOSS

### enumerator HINGE

### enumerator LOG

### enum penalty

*Values:*

### enumerator NONE

### enumerator L1

### enumerator L2

### enumerator ELASTICNET

### enum CRITERION

*Values:*

### enumerator GINI

### enumerator ENTROPY

### enumerator MSE

### enumerator MAE

### enumerator POISSON

### enumerator GAMMA

### enumerator INVERSE_GAUSSIAN

### enumerator CRITERION_END

### enum STORAGE_ORDER

*Values:*

### enumerator COL_MAJOR

### enumerator ROW_MAJOR

### Functions

### void hdbscan(const raft::handle_t &handle, const float \*X, size_t m, size_t n, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric, [HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[HDBSCANParams](#_CPPv4N2ML7HDBSCAN6Common13HDBSCANParamsE) &params, [HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[hdbscan_output](#_CPPv4I00EN2ML7HDBSCAN6Common14hdbscan_outputE)<int64_t, float> &out, float \*core_dists)

Executes [HDBSCAN](#namespaceML_1_1HDBSCAN) clustering on an mxn-dimensional input array, X.

Note that while the algorithm is generally deterministic and should provide matching results between RAPIDS and the Scikit-learn Contrib versions, the construction of the k-nearest neighbors graph and minimum spanning tree can introduce differences between the two algorithms, especially when several nearest neighbors around a point might have the same distance. While the differences in the minimum spanning trees alone might be subtle, they can (and often will) lead to some points being assigned different cluster labels between the two implementations.

* **Parameters:**
  * **handle** – **[in]** raft handle for resource reuse 
  * **X** – **[in]** array (size m, n) on device in row-major format 
  * **m** – number of rows in X 
  * **n** – number of columns in X 
  * **metric** – distance metric to use 
  * **params** – struct of configuration hyper-parameters 
  * **out** – struct of output data and arrays on device 
  * **core_dists** – array (size m, 1) of core distances 

### void build_condensed_hierarchy(const raft::handle_t &handle, const int64_t \*children, const float \*delta, const int64_t \*sizes, int min_cluster_size, int n_leaves, [HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[CondensedHierarchy](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE)<int64_t, float> &condensed_tree)

### void \_extract_clusters(const raft::handle_t &handle, size_t n_leaves, int n_edges, int64_t \*parents, int64_t \*children, float \*lambdas, int64_t \*sizes, int64_t \*labels, float \*probabilities, [HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[CLUSTER_SELECTION_METHOD](#_CPPv4N2ML7HDBSCAN6Common24CLUSTER_SELECTION_METHODE) cluster_selection_method, bool allow_single_cluster, int64_t max_cluster_size, float cluster_selection_epsilon)

### void compute_all_points_membership_vectors(const raft::handle_t &handle, [HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[CondensedHierarchy](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE)<int64_t, float> &condensed_tree, [HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[PredictionData](#_CPPv4I00EN2ML7HDBSCAN6Common14PredictionDataE)<int64_t, float> &prediction_data, const float \*X, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric, float \*membership_vec, size_t batch_size = 4096)

### void compute_membership_vector(const raft::handle_t &handle, [HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[CondensedHierarchy](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE)<int64_t, float> &condensed_tree, [HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[PredictionData](#_CPPv4I00EN2ML7HDBSCAN6Common14PredictionDataE)<int64_t, float> &prediction_data, const float \*X, const float \*points_to_predict, size_t n_prediction_points, int min_samples, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric, float \*membership_vec, size_t batch_size = 4096)

### void out_of_sample_predict(const raft::handle_t &handle, [HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[CondensedHierarchy](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE)<int64_t, float> &condensed_tree, [HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[PredictionData](#_CPPv4I00EN2ML7HDBSCAN6Common14PredictionDataE)<int64_t, float> &prediction_data, const float \*X, int64_t \*labels, const float \*points_to_predict, size_t n_prediction_points, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric, int min_samples, int64_t \*out_labels, float \*out_probabilities)

### template<checked_target T, checked_source U>constexpr [T](#_CPPv4I_14checked_target_14checked_sourceEN2ML11narrow_castE1T1U) narrow_cast([U](#_CPPv4I_14checked_target_14checked_sourceEN2ML11narrow_castE1T1U) value)

Convert `value` to target type `T`, trapping if the value does not fit (negative source with unsigned target, or magnitude exceeding `T's` range). 

Use at sites where an existing API forces a narrowing — e.g. passing a `std::size_t` size to a function that takes `int`, or storing a `pair::first` into an `int` variable. The cast itself is preserved; this helper only ensures it doesn’t silently corrupt the value.

When `T` is strictly wider than `U` the magnitude check is skipped (no bit-level loss is possible), so a misplaced `[narrow_cast](#namespaceML_1acb2938e9f8fafebff42d3942829e41f8)<std::size_t>(int)` on a non-negative value is a free `static_cast`. Sign-loss is still flagged: a negative source with an unsigned target traps regardless of widths, since sign loss is a real correctness bug even on a “widening” conversion.

Example: 
```default
// Was: int n = m_shape.first;             // silent narrow
int n = [ML::narrow_cast<int>](#namespaceML_1acb2938e9f8fafebff42d3942829e41f8)(m_shape.first);  // traps if first > INT_MAX
```

* **Template Parameters:**
  * **T** – target integral type 
  * **U** – source integral type (deduced) 
* **Throws:**
   – if `value` cannot be represented in `T`
* **Returns:**
  `value` as `T`

### template<checked_target T, checked_source U1, checked_source U2, checked_source... Us>constexpr [T](#_CPPv4I_14checked_target_14checked_source_14checked_source_Dp14checked_sourceEN2ML11checked_mulE1T2U12U2Dp2Us) checked_mul([U1](#_CPPv4I_14checked_target_14checked_source_14checked_source_Dp14checked_sourceEN2ML11checked_mulE1T2U12U2Dp2Us) a, [U2](#_CPPv4I_14checked_target_14checked_source_14checked_source_Dp14checked_sourceEN2ML11checked_mulE1T2U12U2Dp2Us) b, [Us](#_CPPv4I_14checked_target_14checked_source_14checked_source_Dp14checked_sourceEN2ML11checked_mulE1T2U12U2Dp2Us)... rest)

Multiply two or more integers in target type `T`, trapping on overflow or on operands that cannot be represented in `T`. 

* **Template Parameters:**
  * **T** – target integral type (typically `std::size_t` or `std::int64_t`) 
  * **U1** – type of the first factor (deduced) 
  * **U2** – type of the second factor (deduced) 
  * **Us** – types of additional factors (deduced) 
* **Throws:**
   – on overflow or unrepresentable operand 
* **Returns:**
  the product as `T`

### template<checked_target T, checked_source U1, checked_source U2, checked_source... Us>constexpr [T](#_CPPv4I_14checked_target_14checked_source_14checked_source_Dp14checked_sourceEN2ML11checked_addE1T2U12U2Dp2Us) checked_add([U1](#_CPPv4I_14checked_target_14checked_source_14checked_source_Dp14checked_sourceEN2ML11checked_addE1T2U12U2Dp2Us) a, [U2](#_CPPv4I_14checked_target_14checked_source_14checked_source_Dp14checked_sourceEN2ML11checked_addE1T2U12U2Dp2Us) b, [Us](#_CPPv4I_14checked_target_14checked_source_14checked_source_Dp14checked_sourceEN2ML11checked_addE1T2U12U2Dp2Us)... rest)

Add two or more integers in target type `T`, trapping on overflow or on operands that cannot be represented in `T`. 

### template<checked_target T, checked_source U1, checked_source U2>constexpr [T](#_CPPv4I_14checked_target_14checked_source_14checked_sourceEN2ML11checked_subE1T2U12U2) checked_sub([U1](#_CPPv4I_14checked_target_14checked_source_14checked_sourceEN2ML11checked_subE1T2U12U2) a, [U2](#_CPPv4I_14checked_target_14checked_source_14checked_sourceEN2ML11checked_subE1T2U12U2) b)

Compute `a` - `b` in target type `T`, trapping on underflow or on operands that cannot be represented in `T`. 

For unsigned `T` this enforces `a` >= `b`. 

### template<checked_target T, checked_source U1, checked_source U2>constexpr [T](#_CPPv4I_14checked_target_14checked_source_14checked_sourceEN2ML11checked_divE1T2U12U2) checked_div([U1](#_CPPv4I_14checked_target_14checked_source_14checked_sourceEN2ML11checked_divE1T2U12U2) a, [U2](#_CPPv4I_14checked_target_14checked_source_14checked_sourceEN2ML11checked_divE1T2U12U2) b)

Compute `a` / `b` in target type `T`, trapping on divide-by-zero (and on signed `INT_MIN / -1` overflow for signed `T`) or on operands that cannot be represented in `T`. 

### inline rapids_logger::sink_ptr default_sink()

Returns the default sink for the global logger. 

If the environment variable `CUML_DEBUG_LOG_FILE` is defined, the default sink is a sink to that file. Otherwise, the default is to dump to stderr.

* **Returns:**
  sink_ptr The sink to use 

### inline std::string default_pattern()

Returns the default log pattern for the global logger. 

* **Returns:**
  std::string The default log pattern. 

### inline rapids_logger::logger &default_logger()

Get the default logger. 

* **Returns:**
  logger& The default logger 

### template<typename enum_solver>inline raft::linalg::paramsTSVD to_raft_params(const [paramsTSVDTemplate](#_CPPv4I0EN2ML18paramsTSVDTemplateE)<[enum_solver](#_CPPv4I0EN2ML14to_raft_paramsEN4raft6linalg10paramsTSVDERK18paramsTSVDTemplateI11enum_solverE)> &ml_prms)

### template<typename enum_solver>inline raft::linalg::paramsPCA to_raft_params(const [paramsPCATemplate](#_CPPv4I0EN2ML17paramsPCATemplateE)<[enum_solver](#_CPPv4I0EN2ML14to_raft_paramsEN4raft6linalg9paramsPCAERK17paramsPCATemplateI11enum_solverE)> &ml_prms)

### void pcaFit(const raft::handle_t &handle, float \*input, float \*components, float \*explained_var, float \*explained_var_ratio, float \*singular_vals, float \*mu, float \*noise_vars, const [paramsPCA](#_CPPv4N2ML9paramsPCAE) &prms)

### void pcaFit(const raft::handle_t &handle, double \*input, double \*components, double \*explained_var, double \*explained_var_ratio, double \*singular_vals, double \*mu, double \*noise_vars, const [paramsPCA](#_CPPv4N2ML9paramsPCAE) &prms)

### void pcaFitTransform(const raft::handle_t &handle, float \*input, float \*trans_input, float \*components, float \*explained_var, float \*explained_var_ratio, float \*singular_vals, float \*mu, float \*noise_vars, const [paramsPCA](#_CPPv4N2ML9paramsPCAE) &prms)

### void pcaFitTransform(const raft::handle_t &handle, double \*input, double \*trans_input, double \*components, double \*explained_var, double \*explained_var_ratio, double \*singular_vals, double \*mu, double \*noise_vars, const [paramsPCA](#_CPPv4N2ML9paramsPCAE) &prms)

### void pcaInverseTransform(const raft::handle_t &handle, float \*trans_input, float \*components, float \*singular_vals, float \*mu, float \*input, const [paramsPCA](#_CPPv4N2ML9paramsPCAE) &prms)

### void pcaInverseTransform(const raft::handle_t &handle, double \*trans_input, double \*components, double \*singular_vals, double \*mu, double \*input, const [paramsPCA](#_CPPv4N2ML9paramsPCAE) &prms)

### void pcaTransform(const raft::handle_t &handle, float \*input, float \*components, float \*trans_input, float \*singular_vals, float \*mu, const [paramsPCA](#_CPPv4N2ML9paramsPCAE) &prms)

### void pcaTransform(const raft::handle_t &handle, double \*input, double \*components, double \*trans_input, double \*singular_vals, double \*mu, const [paramsPCA](#_CPPv4N2ML9paramsPCAE) &prms)

### void tsvdFit(const raft::handle_t &handle, float \*input, float \*components, float \*singular_vals, const [paramsTSVD](#_CPPv4N2ML10paramsTSVDE) &prms)

### void tsvdFit(const raft::handle_t &handle, double \*input, double \*components, double \*singular_vals, const [paramsTSVD](#_CPPv4N2ML10paramsTSVDE) &prms)

### void tsvdInverseTransform(const raft::handle_t &handle, float \*trans_input, float \*components, float \*input, const [paramsTSVD](#_CPPv4N2ML10paramsTSVDE) &prms)

### void tsvdInverseTransform(const raft::handle_t &handle, double \*trans_input, double \*components, double \*input, const [paramsTSVD](#_CPPv4N2ML10paramsTSVDE) &prms)

### void tsvdTransform(const raft::handle_t &handle, float \*input, float \*components, float \*trans_input, const [paramsTSVD](#_CPPv4N2ML10paramsTSVDE) &prms)

### void tsvdTransform(const raft::handle_t &handle, double \*input, double \*components, double \*trans_input, const [paramsTSVD](#_CPPv4N2ML10paramsTSVDE) &prms)

### void tsvdFitTransform(const raft::handle_t &handle, float \*input, float \*trans_input, float \*components, float \*explained_var, float \*explained_var_ratio, float \*singular_vals, const [paramsTSVD](#_CPPv4N2ML10paramsTSVDE) &prms)

### void tsvdFitTransform(const raft::handle_t &handle, double \*input, double \*trans_input, double \*components, double \*explained_var, double \*explained_var_ratio, double \*singular_vals, const [paramsTSVD](#_CPPv4N2ML10paramsTSVDE) &prms)

### template<typename T>[CompactIFForest](#_CPPv4I0EN2ML15CompactIFForestE)<[T](#_CPPv4I0EN2ML17get_compact_treesE15CompactIFForestI1TERKN4raft8handle_tEPK20IsolationForestModelI1TE)> get_compact_trees(const raft::handle_t &handle, const [IsolationForestModel](#_CPPv4I0EN2ML20IsolationForestModelE)<[T](#_CPPv4I0EN2ML17get_compact_treesE15CompactIFForestI1TERKN4raft8handle_tEPK20IsolationForestModelI1TE)> \*model)

Extract compact tree data from a trained model for export. 

Efficiently copies only the used nodes (~400 KB for 100 trees) instead of the full padded storage (~200 MB). 

### double compute_c_normalization(int n)

Compute c(n) = 2H(n-1) - 2(n-1)/n normalization constant. 

### template<typename T>void build_treelite_isolation_forest(TreeliteModelHandle \*model_handle, const raft::handle_t &handle, const [IsolationForestModel](#_CPPv4I0EN2ML20IsolationForestModelE)<[T](#_CPPv4I0EN2ML31build_treelite_isolation_forestEvP19TreeliteModelHandleRKN4raft8handle_tEPK20IsolationForestModelI1TE)> \*forest)

Build a Treelite regression forest from a trained Isolation Forest model. 

The exported Treelite model predicts average path length across trees. The Isolation Forest anomaly score transform, s(x) = 2^(-E[h(x)] / c(n)), is intentionally applied by callers so exported tree structure stays faithful to the trained isolation trees.

* **Parameters:**
  * **model_handle** – **[out]** Treelite model handle owned by the caller 
  * **handle** – **[in]** RAFT handle for GPU resources 
  * **forest** – **[in]** Trained Isolation Forest model 

### void fit(const raft::handle_t &handle, [IsolationForestF](#_CPPv4N2ML16IsolationForestFE) \*forest, const float \*input, size_t n_rows, int n_cols, const [IF_params](#_CPPv4N2ML9IF_paramsE) &params, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

Fit an Isolation Forest model. 

* **Parameters:**
  * **handle** – **[in]** RAFT handle for GPU resources 
  * **forest** – **[out]** Model to populate with trained trees 
  * **input** – **[in]** Training data, column-major [n_rows × n_cols], device pointer 
  * **n_rows** – **[in]** Number of training samples 
  * **n_cols** – **[in]** Number of features 
  * **params** – **[in]** Hyperparameters (n_estimators, max_samples, max_depth, seed) 
  * **verbosity** – **[in]** Logging level 

### void fit(const raft::handle_t &handle, [IsolationForestD](#_CPPv4N2ML16IsolationForestDE) \*forest, const double \*input, size_t n_rows, int n_cols, const [IF_params](#_CPPv4N2ML9IF_paramsE) &params, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

### template<typename T>void fit_treelite(const raft::handle_t &handle, TreeliteModelHandle \*model_handle, const [T](#_CPPv4I0EN2ML12fit_treeliteEvRKN4raft8handle_tEP19TreeliteModelHandlePK1T6size_tiRK9IF_paramsPdPi6size_tN13rapids_logger10level_enumE) \*input, size_t n_rows, int n_cols, const [IF_params](#_CPPv4N2ML9IF_paramsE) &params, double \*c_normalization, int \*feature_indices, size_t feature_indices_size, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

Fit an Isolation Forest and export it as a Treelite model. 

* **Parameters:**
  * **handle** – **[in]** RAFT handle for GPU resources 
  * **model_handle** – **[out]** Treelite model handle owned by the caller 
  * **input** – **[in]** Training data, column-major [n_rows × n_cols], device pointer 
  * **n_rows** – **[in]** Number of training samples 
  * **n_cols** – **[in]** Number of features 
  * **params** – **[in]** Hyperparameters (n_estimators, max_samples, max_depth, seed) 
  * **c_normalization** – **[out]** Normalization constant c(n) for the trained forest, needed to turn average path lengths into anomaly scores 
  * **feature_indices** – **[out]** Host buffer receiving each tree’s sampled feature indices in row-major [n_estimators, resolved max_features] order 
  * **feature_indices_size** – **[in]** Number of elements available in feature_indices 
  * **verbosity** – **[in]** Logging level 

### void score_samples(const raft::handle_t &handle, const [IsolationForestF](#_CPPv4N2ML16IsolationForestFE) \*forest, const float \*input, size_t n_rows, int n_cols, float \*scores, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

Compute anomaly scores. 

Returns scores following the original paper convention (Liu et al. 2008):
* Score ≈ 1.0: anomaly (isolated quickly)
* Score ≈ 0.5: normal (average isolation depth)
* Score ≈ 0.0: very normal (hard to isolate)

* **Parameters:**
  * **handle** – **[in]** RAFT handle for GPU resources 
  * **forest** – **[in]** Trained Isolation Forest model 
  * **input** – **[in]** Test data, row-major [n_rows × n_cols], device pointer 
  * **n_rows** – **[in]** Number of test samples 
  * **n_cols** – **[in]** Number of features (must match training) 
  * **scores** – **[out]** Anomaly scores [n_rows], device pointer 
  * **verbosity** – **[in]** Logging level 

### void score_samples(const raft::handle_t &handle, const [IsolationForestD](#_CPPv4N2ML16IsolationForestDE) \*forest, const double \*input, size_t n_rows, int n_cols, double \*scores, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

### void predict(const raft::handle_t &handle, const [IsolationForestF](#_CPPv4N2ML16IsolationForestFE) \*forest, const float \*input, size_t n_rows, int n_cols, int \*predictions, float threshold = 0.5f, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

Predict anomaly labels. 

* **Parameters:**
  * **handle** – **[in]** RAFT handle for GPU resources 
  * **forest** – **[in]** Trained Isolation Forest model 
  * **input** – **[in]** Test data, row-major [n_rows × n_cols], device pointer 
  * **n_rows** – **[in]** Number of test samples 
  * **n_cols** – **[in]** Number of features (must match training) 
  * **predictions** – **[out]** Labels [n_rows]: 1 = anomaly, -1 = normal, device pointer 
  * **threshold** – **[in]** Score threshold (default 0.5); scores strictly above it are anomalies 
  * **verbosity** – **[in]** Logging level 

### void predict(const raft::handle_t &handle, const [IsolationForestD](#_CPPv4N2ML16IsolationForestDE) \*forest, const double \*input, size_t n_rows, int n_cols, int \*predictions, double threshold = 0.5, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

### [RF_metrics](#_CPPv4N2ML10RF_metricsE) set_all_rf_metrics([RF_type](#_CPPv4N2ML7RF_typeE) rf_type, float accuracy, double mean_abs_error, double mean_squared_error, double median_abs_error)

### [RF_metrics](#_CPPv4N2ML10RF_metricsE) set_rf_metrics_classification(float accuracy)

### [RF_metrics](#_CPPv4N2ML10RF_metricsE) set_rf_metrics_regression(double mean_abs_error, double mean_squared_error, double median_abs_error)

### void print(const [RF_metrics](#_CPPv4N2ML10RF_metricsE) rf_metrics)

### void preprocess_labels(int n_rows, std::vector<int> &labels, std::map<int, int> &labels_map, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

### void postprocess_labels(int n_rows, std::vector<int> &labels, std::map<int, int> &labels_map, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

### template<class T, class L>void delete_rf_metadata([RandomForestMetaData](#_CPPv4I00EN2ML20RandomForestMetaDataE)<[T](#_CPPv4I00EN2ML18delete_rf_metadataEvP20RandomForestMetaDataI1T1LE), [L](#_CPPv4I00EN2ML18delete_rf_metadataEvP20RandomForestMetaDataI1T1LE)> \*forest)

### template<class T, class L>std::string get_rf_summary_text(const [RandomForestMetaData](#_CPPv4I00EN2ML20RandomForestMetaDataE)<[T](#_CPPv4I00EN2ML19get_rf_summary_textENSt6stringEPK20RandomForestMetaDataI1T1LE), [L](#_CPPv4I00EN2ML19get_rf_summary_textENSt6stringEPK20RandomForestMetaDataI1T1LE)> \*forest)

### template<class T, class L>std::string get_rf_detailed_text(const [RandomForestMetaData](#_CPPv4I00EN2ML20RandomForestMetaDataE)<[T](#_CPPv4I00EN2ML20get_rf_detailed_textENSt6stringEPK20RandomForestMetaDataI1T1LE), [L](#_CPPv4I00EN2ML20get_rf_detailed_textENSt6stringEPK20RandomForestMetaDataI1T1LE)> \*forest)

### template<class T, class L>std::string get_rf_json(const [RandomForestMetaData](#_CPPv4I00EN2ML20RandomForestMetaDataE)<[T](#_CPPv4I00EN2ML11get_rf_jsonENSt6stringEPK20RandomForestMetaDataI1T1LE), [L](#_CPPv4I00EN2ML11get_rf_jsonENSt6stringEPK20RandomForestMetaDataI1T1LE)> \*forest)

### template<class T, class L>void build_treelite_forest(TreeliteModelHandle \*model, const [RandomForestMetaData](#_CPPv4I00EN2ML20RandomForestMetaDataE)<[T](#_CPPv4I00EN2ML21build_treelite_forestEvP19TreeliteModelHandlePK20RandomForestMetaDataI1T1LEi), [L](#_CPPv4I00EN2ML21build_treelite_forestEvP19TreeliteModelHandlePK20RandomForestMetaDataI1T1LEi)> \*forest, int num_features)

### template<class T, class L>void compute_feature_importances(const [RandomForestMetaData](#_CPPv4I00EN2ML20RandomForestMetaDataE)<[T](#_CPPv4I00EN2ML27compute_feature_importancesEvPK20RandomForestMetaDataI1T1LEP1T), [L](#_CPPv4I00EN2ML27compute_feature_importancesEvPK20RandomForestMetaDataI1T1LEP1T)> \*forest, [T](#_CPPv4I00EN2ML27compute_feature_importancesEvPK20RandomForestMetaDataI1T1LEP1T) \*importances)

Compute the feature importances of the trained RandomForest model. 

* **Template Parameters:**
  * **T** – data type for input data (float or double). 
  * **L** – data type for labels (int type for classification, T type for regression). 
* **Parameters:**
  * **forest** – **[in]** CPU pointer to [RandomForestMetaData](#structML_1_1RandomForestMetaData)
  * **importances** – **[out]** output feature importance scores 

### void fit(const raft::handle_t &user_handle, [RandomForestClassifierF](#_CPPv4N2ML23RandomForestClassifierFE) \*forest, float \*input, int n_rows, int n_cols, int \*labels, int n_unique_labels, [RF_params](#_CPPv4N2ML9RF_paramsE) rf_params, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info, bool \*bootstrap_masks = nullptr, const double \*sample_weight = nullptr, bool input_row_major = false)

### void fit(const raft::handle_t &user_handle, [RandomForestClassifierD](#_CPPv4N2ML23RandomForestClassifierDE) \*forest, double \*input, int n_rows, int n_cols, int \*labels, int n_unique_labels, [RF_params](#_CPPv4N2ML9RF_paramsE) rf_params, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info, bool \*bootstrap_masks = nullptr, const double \*sample_weight = nullptr, bool input_row_major = false)

### template<typename T, typename L>void fit_treelite(const raft::handle_t &user_handle, TreeliteModelHandle \*model, [T](#_CPPv4I00EN2ML12fit_treeliteEvRKN4raft8handle_tEP19TreeliteModelHandleP1TiiP1Li9RF_paramsPbP1TN13rapids_logger10level_enumEPKdb) \*input, int n_rows, int n_cols, [L](#_CPPv4I00EN2ML12fit_treeliteEvRKN4raft8handle_tEP19TreeliteModelHandleP1TiiP1Li9RF_paramsPbP1TN13rapids_logger10level_enumEPKdb) \*labels, int n_unique_labels, [RF_params](#_CPPv4N2ML9RF_paramsE) rf_params, bool \*bootstrap_masks, [T](#_CPPv4I00EN2ML12fit_treeliteEvRKN4raft8handle_tEP19TreeliteModelHandleP1TiiP1Li9RF_paramsPbP1TN13rapids_logger10level_enumEPKdb) \*feature_importances, rapids_logger::level_enum verbosity, const double \*sample_weight = nullptr, bool input_row_major = false)

Train a random forest classifier and export it as a Treelite model. 

* **Parameters:**
  * **user_handle** – **[in]** RAFT handle for stream and allocator resources. 
  * **model** – **[out]** Treelite model handle populated by training. 
  * **input** – **[in]** Training data, column-major by default or row-major when input_row_major is true. 
  * **n_rows** – **[in]** Number of rows in input. 
  * **n_cols** – **[in]** Number of columns in input. 
  * **labels** – **[in]** Training labels. 
  * **n_unique_labels** – **[in]** Number of unique classes in labels. 
  * **rf_params** – **[in]** Random forest training parameters. 
  * **bootstrap_masks** – **[in]** Optional bootstrap masks. 
  * **feature_importances** – **[out]** Output feature importances. 
  * **verbosity** – **[in]** Logging verbosity. 
  * **sample_weight** – **[in]** Optional per-row sample weights. 
  * **input_row_major** – **[in]** Whether input is row-major instead of column-major. 

### void predict(const raft::handle_t &user_handle, const [RandomForestClassifierF](#_CPPv4N2ML23RandomForestClassifierFE) \*forest, const float \*input, int n_rows, int n_cols, int \*predictions, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

### void predict(const raft::handle_t &user_handle, const [RandomForestClassifierD](#_CPPv4N2ML23RandomForestClassifierDE) \*forest, const double \*input, int n_rows, int n_cols, int \*predictions, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

### [RF_metrics](#_CPPv4N2ML10RF_metricsE) score(const raft::handle_t &user_handle, const [RandomForestClassifierF](#_CPPv4N2ML23RandomForestClassifierFE) \*forest, const int \*ref_labels, int n_rows, const int \*predictions, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

### [RF_metrics](#_CPPv4N2ML10RF_metricsE) score(const raft::handle_t &user_handle, const [RandomForestClassifierD](#_CPPv4N2ML23RandomForestClassifierDE) \*forest, const int \*ref_labels, int n_rows, const int \*predictions, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

### [RF_params](#_CPPv4N2ML9RF_paramsE) set_rf_params(int max_depth, int max_leaves, float max_features, int max_n_bins, int min_samples_leaf, int min_samples_split, float min_impurity_decrease, bool bootstrap, int n_trees, float max_samples, uint64_t seed, [CRITERION](#_CPPv4N2ML9CRITERIONE) split_criterion, int cfg_n_streams, int max_batch_size)

### void fit(const raft::handle_t &user_handle, [RandomForestRegressorF](#_CPPv4N2ML22RandomForestRegressorFE) \*forest, float \*input, int n_rows, int n_cols, float \*labels, [RF_params](#_CPPv4N2ML9RF_paramsE) rf_params, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info, bool \*bootstrap_masks = nullptr, const double \*sample_weight = nullptr, bool input_row_major = false)

### void fit(const raft::handle_t &user_handle, [RandomForestRegressorD](#_CPPv4N2ML22RandomForestRegressorDE) \*forest, double \*input, int n_rows, int n_cols, double \*labels, [RF_params](#_CPPv4N2ML9RF_paramsE) rf_params, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info, bool \*bootstrap_masks = nullptr, const double \*sample_weight = nullptr, bool input_row_major = false)

### template<typename T, typename L>void fit_treelite(const raft::handle_t &user_handle, TreeliteModelHandle \*model, [T](#_CPPv4I00EN2ML12fit_treeliteEvRKN4raft8handle_tEP19TreeliteModelHandleP1TiiP1L9RF_paramsPbP1TN13rapids_logger10level_enumEPKdb) \*input, int n_rows, int n_cols, [L](#_CPPv4I00EN2ML12fit_treeliteEvRKN4raft8handle_tEP19TreeliteModelHandleP1TiiP1L9RF_paramsPbP1TN13rapids_logger10level_enumEPKdb) \*labels, [RF_params](#_CPPv4N2ML9RF_paramsE) rf_params, bool \*bootstrap_masks, [T](#_CPPv4I00EN2ML12fit_treeliteEvRKN4raft8handle_tEP19TreeliteModelHandleP1TiiP1L9RF_paramsPbP1TN13rapids_logger10level_enumEPKdb) \*feature_importances, rapids_logger::level_enum verbosity, const double \*sample_weight = nullptr, bool input_row_major = false)

Train a random forest regressor and export it as a Treelite model. 

* **Parameters:**
  * **user_handle** – **[in]** RAFT handle for stream and allocator resources. 
  * **model** – **[out]** Treelite model handle populated by training. 
  * **input** – **[in]** Training data, column-major by default or row-major when input_row_major is true. 
  * **n_rows** – **[in]** Number of rows in input. 
  * **n_cols** – **[in]** Number of columns in input. 
  * **labels** – **[in]** Training labels. 
  * **rf_params** – **[in]** Random forest training parameters. 
  * **bootstrap_masks** – **[in]** Optional bootstrap masks. 
  * **feature_importances** – **[out]** Output feature importances. 
  * **verbosity** – **[in]** Logging verbosity. 
  * **sample_weight** – **[in]** Optional per-row sample weights. 
  * **input_row_major** – **[in]** Whether input is row-major instead of column-major. 

### void predict(const raft::handle_t &user_handle, const [RandomForestRegressorF](#_CPPv4N2ML22RandomForestRegressorFE) \*forest, const float \*input, int n_rows, int n_cols, float \*predictions, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

### void predict(const raft::handle_t &user_handle, const [RandomForestRegressorD](#_CPPv4N2ML22RandomForestRegressorDE) \*forest, const double \*input, int n_rows, int n_cols, double \*predictions, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

### [RF_metrics](#_CPPv4N2ML10RF_metricsE) score(const raft::handle_t &user_handle, const [RandomForestRegressorF](#_CPPv4N2ML22RandomForestRegressorFE) \*forest, const float \*ref_labels, int n_rows, const float \*predictions, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

### [RF_metrics](#_CPPv4N2ML10RF_metricsE) score(const raft::handle_t &user_handle, const [RandomForestRegressorD](#_CPPv4N2ML22RandomForestRegressorDE) \*forest, const double \*ref_labels, int n_rows, const double \*predictions, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

### void TSNE_fit(const raft::handle_t &handle, float \*X, float \*Y, int n, int p, int64_t \*knn_indices, float \*knn_dists, [TSNEParams](#_CPPv4N2ML10TSNEParamsE) &params, float \*kl_div = nullptr, int \*n_iter = nullptr)

Dimensionality reduction via TSNE using Barnes-Hut, Fourier Interpolation, or naive methods. or brute force O(N^2). 


The CUDA implementation is derived from the excellent CannyLabs open source implementation here: [https://github.com/CannyLab/tsne-cuda/](https://github.com/CannyLab/tsne-cuda/). The CannyLabs code is licensed according to the conditions in cuml/cpp/src/tsne/cannylabs_tsne_license.txt. A full description of their approach is available in their article t-SNE-CUDA: GPU-Accelerated t-SNE and its Applications to Modern Data ([https://arxiv.org/abs/1807.11824](https://arxiv.org/abs/1807.11824)). 

* **Parameters:**
  * **handle** – **[in]** The GPU handle. 
  * **X** – **[in]** The row-major dataset in device memory. 
  * **Y** – **[out]** The column-major final embedding in device memory 
  * **n** – **[in]** Number of rows in data X. 
  * **p** – **[in]** Number of columns in data X. 
  * **knn_indices** – **[in]** Array containing nearest neighbors indices. 
  * **knn_dists** – **[in]** Array containing nearest neighbors distances. 
  * **params** – **[in]** Parameters for TSNE model 
  * **kl_div** – **[out]** (optional) KL divergence output 
  * **n_iter** – **[out]** (optional) The number of iterations TSNE ran for.

### void TSNE_fit_sparse(const raft::handle_t &handle, int \*indptr, int \*indices, float \*data, float \*Y, int nnz, int n, int p, int \*knn_indices, float \*knn_dists, [TSNEParams](#_CPPv4N2ML10TSNEParamsE) &params, float \*kl_div = nullptr, int \*n_iter = nullptr)

Dimensionality reduction via TSNE using either Barnes Hut O(NlogN) or brute force O(N^2). 


The CUDA implementation is derived from the excellent CannyLabs open source implementation here: [https://github.com/CannyLab/tsne-cuda/](https://github.com/CannyLab/tsne-cuda/). The CannyLabs code is licensed according to the conditions in cuml/cpp/src/tsne/cannylabs_tsne_license.txt. A full description of their approach is available in their article t-SNE-CUDA: GPU-Accelerated t-SNE and its Applications to Modern Data ([https://arxiv.org/abs/1807.11824](https://arxiv.org/abs/1807.11824)). 

* **Parameters:**
  * **handle** – **[in]** The GPU handle. 
  * **indptr** – **[in]** indptr of CSR dataset. 
  * **indices** – **[in]** indices of CSR dataset. 
  * **data** – **[in]** data of CSR dataset. 
  * **Y** – **[out]** The final embedding. 
  * **nnz** – **[in]** The number of non-zero entries in the CSR. 
  * **n** – **[in]** Number of rows in data X. 
  * **p** – **[in]** Number of columns in data X. 
  * **knn_indices** – **[in]** Array containing nearest neighbors indices. 
  * **knn_dists** – **[in]** Array containing nearest neighbors distances. 
  * **params** – **[in]** Parameters for TSNE model 
  * **kl_div** – **[out]** (optional) KL divergence output 
  * **n_iter** – **[out]** (optional) The number of iterations TSNE ran for.

### void brute_force_knn(const raft::handle_t &handle, std::vector<float\*> &input, std::vector<int> &sizes, int D, float \*search_items, int n, int64_t \*res_I, float \*res_D, int k, bool rowMajorIndex = false, bool rowMajorQuery = false, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric = [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE)::[L2Expanded](#_CPPv4N2ML8distance12DistanceType10L2ExpandedE), float metric_arg = 2.0f, std::vector<int64_t> \*translations = nullptr)

Flat C++ API function to perform a brute force knn on a series of input arrays and combine the results into a single output array for indexes and distances. 

* **Parameters:**
  * **handle** – **[in]** RAFT handle 
  * **input** – **[in]** vector of pointers to the input arrays 
  * **sizes** – **[in]** vector of sizes of input arrays 
  * **D** – **[in]** the dimensionality of the arrays 
  * **search_items** – **[in]** array of items to search of dimensionality D 
  * **n** – **[in]** number of rows in search_items 
  * **res_I** – **[out]** the resulting index array of size n \* k 
  * **res_D** – **[out]** the resulting distance array of size n \* k 
  * **k** – **[in]** the number of nearest neighbors to return 
  * **rowMajorIndex** – **[in]** are the index arrays in row-major order? 
  * **rowMajorQuery** – **[in]** are the query arrays in row-major order? 
  * **metric** – **[in]** distance metric to use. Euclidean (L2) is used by default 
  * **metric_arg** – **[in]** the value of `p` for Minkowski (l-p) distances. This is ignored if the metric_type is not Minkowski. 
  * **translations** – **[in]** translation ids for indices when index rows represent non-contiguous partitions 

### void rbc_build_index(const raft::handle_t &handle, std::uintptr_t &rbc_index, float \*X, int64_t n_rows, int64_t n_cols, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric)

### void rbc_knn_query(const raft::handle_t &handle, const std::uintptr_t &rbc_index, uint32_t k, const float \*search_items, uint32_t n_search_items, int64_t dim, int64_t \*out_inds, float \*out_dists)

### void rbc_radius_neighbors_graph(const raft::handle_t &handle, const std::uintptr_t &rbc_index, const float \*query, int64_t n_query, int64_t dim, float radius, int64_t \*adj_indptr, int64_t \*adj_indices = nullptr, int64_t nnz = 0)

Perform a radius neighbors query on the fit index. 

A single query requires two calls to this API:
* The first call should pass adj_indices=nullptr and nnz=0. This will fill in adj_indptr, letting you get the size needed for adj_indices.
* The second call should pass adj_indices and nnz, an array of size nnz=adj_indptr[-1]. This will fill in adj_indices.

* **Parameters:**
  * **handle** – **[in]** RAFT handle 
  * **rbc_index** – **[in]** the fit RBC index 
  * **query** – **[in]** the query points as a C-contiguous array 
  * **n_query** – **[in]** number of rows in the query 
  * **dim** – **[in]** number of columns in the query 
  * **radius** – **[in]** the neighborhood radius 
  * **adj_indptr** – **[out]** the indptr array in output CSR adjacency matrix, of shape n_query + 1. 
  * **adj_indices** – **[out]** the indices array in the output CSR adjacency matrix, of shape adj_indptr[-1]. Should be NULL on the first call. 
  * **nnz** – **[in]** the number of elements in adj_indices, or 0 on the first call. 

### void rbc_free_index(std::uintptr_t rbc_index)

Free the RBC index. 

* **Parameters:**
  **rbc_index** – **[in]** pointer to the index to free 

### void approx_knn_build_index(raft::handle_t &handle, [knnIndex](#_CPPv4N2ML8knnIndexE) \*index, [knnIndexParam](#_CPPv4N2ML13knnIndexParamE) \*params, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric, float metricArg, float \*index_array, int n, int D)

Flat C++ API function to build an approximate nearest neighbors index from an index array and a set of parameters. 

* **Parameters:**
  * **handle** – **[in]** RAFT handle 
  * **index** – **[out]** index to be built 
  * **params** – **[in]** parametrization of the index to be built 
  * **metric** – **[in]** distance metric to use. Euclidean (L2) is used by default 
  * **metricArg** – **[in]** metric argument 
  * **index_array** – **[in]** the index array to build the index with 
  * **n** – **[in]** number of rows in the index array 
  * **D** – **[in]** the dimensionality of the index array 

### void approx_knn_search(raft::handle_t &handle, float \*distances, int64_t \*indices, [knnIndex](#_CPPv4N2ML8knnIndexE) \*index, int k, float \*query_array, int n)

Flat C++ API function to perform an approximate nearest neighbors search from previously built index and a query array. 

* **Parameters:**
  * **handle** – **[in]** RAFT handle 
  * **distances** – **[out]** distances of the nearest neighbors toward their query point 
  * **indices** – **[out]** indices of the nearest neighbors 
  * **index** – **[in]** index to perform a search with 
  * **k** – **[in]** the number of nearest neighbors to search for 
  * **query_array** – **[in]** the query to perform a search with 
  * **n** – **[in]** number of rows in the query array 

### void knn_classify(raft::handle_t &handle, int \*out, int64_t \*knn_indices, std::vector<int\*> &y, size_t n_index_rows, size_t n_query_rows, int k, float \*sample_weight = nullptr)

Flat C++ API function to perform a knn classification using a given a vector of label arrays. This supports multilabel classification by classifying on multiple label arrays. Note that each label is classified independently, as is done in scikit-learn. 

* **Parameters:**
  * **handle** – **[in]** RAFT handle 
  * **out** – **[out]** output array on device (size n_samples \* size of y vector) 
  * **knn_indices** – **[in]** index array on device resulting from knn query (size n_samples \* k) 
  * **y** – **[in]** vector of label arrays on device vector size is number of (size n_samples) 
  * **n_index_rows** – **[in]** number of vertices in index (eg. size of each y array) 
  * **n_query_rows** – **[in]** number of samples in knn_indices 
  * **k** – **[in]** number of nearest neighbors in knn_indices 
  * **sample_weight** – **[in]** optional pre-computed weight array on device (size n_samples \* k). If nullptr, uniform weights are used. 

### void knn_regress(raft::handle_t &handle, float \*out, int64_t \*knn_indices, std::vector<float\*> &y, size_t n_index_rows, size_t n_query_rows, int k, float \*sample_weight = nullptr)

Flat C++ API function to perform a knn regression using a given a vector of label arrays. This supports multilabel regression by classifying on multiple label arrays. Note that each label is classified independently, as is done in scikit-learn. 

* **Parameters:**
  * **handle** – **[in]** RAFT handle 
  * **out** – **[out]** output array on device (size n_samples) 
  * **knn_indices** – **[in]** array on device of knn indices (size n_samples \* k) 
  * **y** – **[in]** array of labels on device (size n_samples) 
  * **n_index_rows** – **[in]** number of vertices in index (eg. size of each y array) 
  * **n_query_rows** – **[in]** number of samples in knn_indices and out 
  * **k** – **[in]** number of nearest neighbors in knn_indices 
  * **sample_weight** – **[in]** optional pre-computed weight array on device (size n_samples \* k). If nullptr, uniform weights are used. 

### void knn_regress(raft::handle_t &handle, double \*out, int64_t \*knn_indices, std::vector<double\*> &y, size_t n_index_rows, size_t n_query_rows, int k, float \*sample_weight = nullptr)

### void knn_class_proba(raft::handle_t &handle, std::vector<float\*> &out, int64_t \*knn_indices, std::vector<int\*> &y, size_t n_index_rows, size_t n_query_rows, int k, float \*sample_weight = nullptr)

Flat C++ API function to compute knn class probabilities using a vector of device arrays containing discrete class labels. Note that the output is a vector, which is. 

* **Parameters:**
  * **handle** – **[in]** RAFT handle 
  * **out** – **[out]** vector of output arrays on device. vector size = n_outputs. Each array should have size(n_samples, n_classes) 
  * **knn_indices** – **[in]** array on device of knn indices (size n_samples \* k) 
  * **y** – **[in]** array of labels on device (size n_samples) 
  * **n_index_rows** – **[in]** number of labels in y 
  * **n_query_rows** – **[in]** number of rows in knn_indices and out 
  * **k** – **[in]** number of nearest neighbors in knn_indices 
  * **sample_weight** – **[in]** optional pre-computed weight array on device (size n_samples \* k). If nullptr, uniform weights are used. 

### inline void PUSH_RANGE(const char \*name, cudaStream_t stream)

Push a named nvtx range. 

### *Deprecated:*

Use new raft::common::nvtx::push_range from <raft/core/nvtx.hpp>

* **Parameters:**
  * **name** – range name 
  * **stream** – unused 

### inline void POP_RANGE(cudaStream_t stream)

Pop the latest nvtx range. 

### *Deprecated:*

Use new raft::common::nvtx::pop_range from <raft/core/nvtx.hpp>

* **Parameters:**
  **stream** – unused 

### inline void PUSH_RANGE(const char \*name)

Push a named nvtx range. 

### *Deprecated:*

Use new raft::common::nvtx::push_range from <raft/core/nvtx.hpp>

* **Parameters:**
  **name** – range name 

### inline void POP_RANGE()

Pop the latest range  

### *Deprecated:*

Use new raft::common::nvtx::pop_range from <raft/core/nvtx.hpp>

### template<typename T>inline void col_ref(const [SimpleDenseMat](#_CPPv4I0EN2ML14SimpleDenseMatE)<[T](#_CPPv4I0EN2ML7col_refEvRK14SimpleDenseMatI1TER9SimpleVecI1TEi)> &mat, [SimpleVec](#_CPPv4I0EN2ML9SimpleVecE)<[T](#_CPPv4I0EN2ML7col_refEvRK14SimpleDenseMatI1TER9SimpleVecI1TEi)> &mask_vec, int c)

### template<typename T>inline void col_slice(const [SimpleDenseMat](#_CPPv4I0EN2ML14SimpleDenseMatE)<[T](#_CPPv4I0EN2ML9col_sliceEvRK14SimpleDenseMatI1TER14SimpleDenseMatI1TEii)> &mat, [SimpleDenseMat](#_CPPv4I0EN2ML14SimpleDenseMatE)<[T](#_CPPv4I0EN2ML9col_sliceEvRK14SimpleDenseMatI1TER14SimpleDenseMatI1TEii)> &mask_mat, int c_from, int c_to)

### template<typename T>inline [T](#_CPPv4I0EN2ML3dotE1TRK9SimpleVecI1TERK9SimpleVecI1TEP1T12cudaStream_t) dot(const [SimpleVec](#_CPPv4I0EN2ML9SimpleVecE)<[T](#_CPPv4I0EN2ML3dotE1TRK9SimpleVecI1TERK9SimpleVecI1TEP1T12cudaStream_t)> &u, const [SimpleVec](#_CPPv4I0EN2ML9SimpleVecE)<[T](#_CPPv4I0EN2ML3dotE1TRK9SimpleVecI1TERK9SimpleVecI1TEP1T12cudaStream_t)> &v, [T](#_CPPv4I0EN2ML3dotE1TRK9SimpleVecI1TERK9SimpleVecI1TEP1T12cudaStream_t) \*tmp_dev, cudaStream_t stream)

### template<typename T>inline [T](#_CPPv4I0EN2ML11squaredNormE1TRK9SimpleVecI1TEP1T12cudaStream_t) squaredNorm(const [SimpleVec](#_CPPv4I0EN2ML9SimpleVecE)<[T](#_CPPv4I0EN2ML11squaredNormE1TRK9SimpleVecI1TEP1T12cudaStream_t)> &u, [T](#_CPPv4I0EN2ML11squaredNormE1TRK9SimpleVecI1TEP1T12cudaStream_t) \*tmp_dev, cudaStream_t stream)

### template<typename T>inline [T](#_CPPv4I0EN2ML6nrmMaxE1TRK9SimpleVecI1TEP1T12cudaStream_t) nrmMax(const [SimpleVec](#_CPPv4I0EN2ML9SimpleVecE)<[T](#_CPPv4I0EN2ML6nrmMaxE1TRK9SimpleVecI1TEP1T12cudaStream_t)> &u, [T](#_CPPv4I0EN2ML6nrmMaxE1TRK9SimpleVecI1TEP1T12cudaStream_t) \*tmp_dev, cudaStream_t stream)

### template<typename T>inline [T](#_CPPv4I0EN2ML4nrm2E1TRK9SimpleVecI1TEP1T12cudaStream_t) nrm2(const [SimpleVec](#_CPPv4I0EN2ML9SimpleVecE)<[T](#_CPPv4I0EN2ML4nrm2E1TRK9SimpleVecI1TEP1T12cudaStream_t)> &u, [T](#_CPPv4I0EN2ML4nrm2E1TRK9SimpleVecI1TEP1T12cudaStream_t) \*tmp_dev, cudaStream_t stream)

### template<typename T>inline [T](#_CPPv4I0EN2ML4nrm1E1TRK9SimpleVecI1TEP1T12cudaStream_t) nrm1(const [SimpleVec](#_CPPv4I0EN2ML9SimpleVecE)<[T](#_CPPv4I0EN2ML4nrm1E1TRK9SimpleVecI1TEP1T12cudaStream_t)> &u, [T](#_CPPv4I0EN2ML4nrm1E1TRK9SimpleVecI1TEP1T12cudaStream_t) \*tmp_dev, cudaStream_t stream)

### template<typename T>std::ostream &operator<<(std::ostream &os, const [SimpleVec](#_CPPv4I0EN2ML9SimpleVecE)<[T](#_CPPv4I0EN2MLlsERNSt7ostreamERNSt7ostreamERK9SimpleVecI1TE)> &v)

### template<typename T>std::ostream &operator<<(std::ostream &os, const [SimpleDenseMat](#_CPPv4I0EN2ML14SimpleDenseMatE)<[T](#_CPPv4I0EN2MLlsERNSt7ostreamERNSt7ostreamERK14SimpleDenseMatI1TE)> &mat)

### template<typename T, typename I = int>inline void check_csr(const [SimpleSparseMat](#_CPPv4I00EN2ML15SimpleSparseMatE)<[T](#_CPPv4I00EN2ML9check_csrEvRK15SimpleSparseMatI1T1IE12cudaStream_t), [I](#_CPPv4I00EN2ML9check_csrEvRK15SimpleSparseMatI1T1IE12cudaStream_t)> &mat, cudaStream_t stream)

### template<typename T, typename I = int>std::ostream &operator<<(std::ostream &os, const [SimpleSparseMat](#_CPPv4I00EN2ML15SimpleSparseMatE)<[T](#_CPPv4I00EN2MLlsERNSt7ostreamERNSt7ostreamERK15SimpleSparseMatI1T1IE), [I](#_CPPv4I00EN2MLlsERNSt7ostreamERNSt7ostreamERK15SimpleSparseMatI1T1IE)> &mat)

### inline int get_device(const void \*ptr)

### inline cudaMemoryType memory_type(const void \*p)

### inline bool is_device_or_managed_type(const void \*p)

### template<typename T>struct CompactIFForest

 *#include <isolation_forest.hpp>*

Compact tree data returned by [get_compact_trees()](#namespaceML_1a0cf9a006080ab7c12c38460ac0946439). Contains all used nodes concatenated, with per-tree metadata. 

### Public Members

### std::vector<[IFNodeCompact](#_CPPv4I0EN2ML13IFNodeCompactE)<[T](#_CPPv4I0EN2ML15CompactIFForestE)>> nodes

All used nodes, trees concatenated. 

### std::vector<int> tree_offsets

Start index in nodes[] for each tree. 

### std::vector<int> tree_n_nodes

Number of nodes per tree. 

### std::vector<int> tree_max_depth

Max depth per tree. 

### struct IF_params

 *#include <isolation_forest.hpp>*

Isolation Forest hyperparameters. 

### Public Members

### int n_estimators = 100

Number of isolation trees. 

### int max_samples = 256

Samples per tree (default 256). 

### int max_depth = -1

Max depth (-1 = auto: ceil(log2(max_samples))). 

### int max_features = -1

Features sampled per tree (-1 = all features). 

### bool bootstrap = false

If true, sample rows with replacement. 

### uint64_t seed = 0

Random seed. 

### template<typename T>struct IFNodeCompact

 *#include <isolation_forest.hpp>*

Compact node representation (matches internal IFNode layout). 

Internal nodes: feature_idx >= 0, threshold is split value Leaf nodes: feature_idx = -1, threshold stores pre-computed path length 

### template<class T>struct IsolationForestModel

 *#include <isolation_forest.hpp>*

Trained Isolation Forest model. 

### Public Members

### [IF_params](#_CPPv4N2ML9IF_paramsE) params

Hyperparameters used for training. 

### int n_features = 0

Number of features in training data. 

### int n_features_per_tree = 0

Features sampled per tree. 

### int n_samples_per_tree = 0

Samples used per tree (for c(n) calculation). 

### double c_normalization = 0

Precomputed c(n) normalization constant. 

### int max_nodes_per_tree = 0

Allocated node capacity per tree. 

### [rmm](https://docs.nvidia.com/rmm/latest/cpp/rmm_namespace/#_CPPv43rmm)::[device_buffer](https://docs.nvidia.com/rmm/latest/cpp/data_containers/#_CPPv4N3rmm13device_bufferE) global_feature_indices

Optional per-tree sampled feature ids. 

### [rmm](https://docs.nvidia.com/rmm/latest/cpp/rmm_namespace/#_CPPv43rmm)::[device_buffer](https://docs.nvidia.com/rmm/latest/cpp/data_containers/#_CPPv4N3rmm13device_bufferE) global_nodes

Device memory for global-memory IFNode array. 

### [rmm](https://docs.nvidia.com/rmm/latest/cpp/rmm_namespace/#_CPPv43rmm)::[device_buffer](https://docs.nvidia.com/rmm/latest/cpp/data_containers/#_CPPv4N3rmm13device_bufferE) global_tree_offsets

Per-tree base offset in global_nodes. 

### [rmm](https://docs.nvidia.com/rmm/latest/cpp/rmm_namespace/#_CPPv43rmm)::[device_buffer](https://docs.nvidia.com/rmm/latest/cpp/data_containers/#_CPPv4N3rmm13device_bufferE) global_tree_n_nodes

Per-tree used node counts. 

### [rmm](https://docs.nvidia.com/rmm/latest/cpp/rmm_namespace/#_CPPv43rmm)::[device_buffer](https://docs.nvidia.com/rmm/latest/cpp/data_containers/#_CPPv4N3rmm13device_bufferE) global_tree_max_depth

Per-tree max depth metadata. 

### struct IVFFlatParam : public [ML](#_CPPv42ML)::[IVFParam](#_CPPv4N2ML8IVFParamE)

 *#include <knn.hpp>*

### struct IVFParam : public [ML](#_CPPv42ML)::[knnIndexParam](#_CPPv4N2ML13knnIndexParamE)

 *#include <knn.hpp>*

Subclassed by [ML::IVFFlatParam](#structML_1_1IVFFlatParam), [ML::IVFPQParam](#structML_1_1IVFPQParam)

### struct IVFPQParam : public [ML](#_CPPv42ML)::[IVFParam](#_CPPv4N2ML8IVFParamE)

 *#include <knn.hpp>*

### template<typename value_idx, typename value_t>struct knn_graph

 *#include <common.hpp>*

Simple container for [KNN](#namespaceML_1_1KNN) graph properties 

* **Template Parameters:**
  * **value_idx** – 
  * **value_t** – 

### struct knnIndex

 *#include <knn.hpp>*

### struct knnIndexParam

 *#include <knn.hpp>*

Subclassed by [ML::IVFParam](#structML_1_1IVFParam)

### template<typename T>struct manifold_dense_inputs_t : public [ML](#_CPPv42ML)::[manifold_inputs_t](#_CPPv4I0EN2ML17manifold_inputs_tE)<[T](#_CPPv4I0EN2ML23manifold_dense_inputs_tE)>

 *#include <common.hpp>*

Dense input to manifold learning algorithms 

* **Template Parameters:**
  **T** – 

### template<typename T>struct manifold_inputs_t

 *#include <common.hpp>*

Base struct for representing inputs to manifold learning algorithms. 

* **Template Parameters:**
  **T** – 

Subclassed by [ML::manifold_dense_inputs_t< T >](#structML_1_1manifold__dense__inputs__t), [ML::manifold_sparse_inputs_t< value_idx, T >](#structML_1_1manifold__sparse__inputs__t)

### template<typename value_idx, typename value_t>struct manifold_precomputed_knn_inputs_t : public [ML](#_CPPv42ML)::[manifold_inputs_t](#_CPPv4I0EN2ML17manifold_inputs_tE)<[value_t](#_CPPv4I00EN2ML33manifold_precomputed_knn_inputs_tE)>

 *#include <common.hpp>*

Precomputed [KNN](#namespaceML_1_1KNN) graph input to manifold learning algorithms 

* **Template Parameters:**
  * **value_idx** – 
  * **value_t** – 

### template<typename value_idx, typename T>struct manifold_sparse_inputs_t : public [ML](#_CPPv42ML)::[manifold_inputs_t](#_CPPv4I0EN2ML17manifold_inputs_tE)<[T](#_CPPv4I00EN2ML24manifold_sparse_inputs_tE)>

 *#include <common.hpp>*

[Sparse](#namespaceML_1_1Sparse) CSR input to manifold learning algorithms 

* **Template Parameters:**
  * **value_idx** – 
  * **T** – 

### class params

 *#include <params.hpp>*

Subclassed by [ML::paramsSolver](#classML_1_1paramsSolver)

### template<typename enum_solver = [solver](#_CPPv4N2ML6solverE)>class paramsPCATemplate : public [ML](#_CPPv42ML)::[paramsTSVDTemplate](#_CPPv4I0EN2ML18paramsTSVDTemplateE)<[solver](#_CPPv4N2ML6solverE)>

 *#include <params.hpp>*

structure for pca parameters. Ref: [http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html](http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html)

* **Param n_components:**
  Number of components to keep. if n_components is not set all components are kept: 
* **Param copy:**
  If False, data passed to fit are overwritten and running fit(X).transform(X) will not yield the expected results, use fit_transform(X) instead. 
* **Param whiten:**
  When True (False by default) the components_ vectors are multiplied by the square root of n_samples and then divided by the singular values to ensure uncorrelated outputs with unit component-wise variances. 
* **Param algorithm:**
  the solver to be used in [PCA](#namespaceML_1_1PCA). 
* **Param tol:**
  Tolerance for singular values computed by the Jacobi solver 
* **Param n_iterations:**
  Number of iterations for the power method computed by the Jacobi solver 
* **Param verbose:**
  0: no error message printing, 1: print error messages 

### class paramsSolver : public [ML](#_CPPv42ML)::[params](#_CPPv4N2ML6paramsE)

 *#include <params.hpp>*

Subclassed by [ML::paramsTSVDTemplate< mg_solver >](#classML_1_1paramsTSVDTemplate), [ML::paramsTSVDTemplate< solver >](#classML_1_1paramsTSVDTemplate), [ML::paramsTSVDTemplate< enum_solver >](#classML_1_1paramsTSVDTemplate)

### template<typename enum_solver = [solver](#_CPPv4N2ML6solverE)>class paramsTSVDTemplate : public [ML](#_CPPv42ML)::[paramsSolver](#_CPPv4N2ML12paramsSolverE)

 *#include <params.hpp>*

### template<typename T>class pinned_host_vector

 *#include <pinned_host_vector.hpp>*

### template<class T, class L>struct RandomForestMetaData

 *#include <randomforest.hpp>*

### Public Members

### int n_features = 0

Number of features in the training data. 

### struct RF_metrics

 *#include <randomforest.hpp>*

### struct RF_params

 *#include <randomforest.hpp>*

### Public Members

### int n_trees

Number of decision trees in the random forest. 

### bool bootstrap

Control bootstrapping. If bootstrapping is set to true, bootstrapped samples are used for building each tree. Bootstrapped sampling is done by randomly drawing round(max_samples \* n_samples) number of samples with replacement. More on bootstrapping: [https://en.wikipedia.org/wiki/Bootstrap_aggregating](https://en.wikipedia.org/wiki/Bootstrap_aggregating) If bootstrapping is set to false, whole dataset is used to build each tree. 

### float max_samples

Ratio of dataset rows used while fitting each tree. 

### uint64_t seed

Decision tree training hyper parameter struct. random seed 

### int n_streams

Number of concurrent GPU streams for parallel tree building. Each stream is independently managed by CPU thread. N streams need N times RF workspace. 

### template<typename T>struct SimpleDenseMat : public [ML](#_CPPv42ML)::[SimpleMat](#_CPPv4I0EN2ML9SimpleMatE)<[T](#_CPPv4I0EN2ML14SimpleDenseMatE)>

 *#include <dense.hpp>*

Subclassed by [ML::SimpleMatOwning< T >](#structML_1_1SimpleMatOwning), [ML::SimpleVec< T >](#structML_1_1SimpleVec)

### Public Functions

### inline virtual void gemmb(const raft::handle_t &handle, const [T](#_CPPv4I0EN2ML14SimpleDenseMatE) alpha, const [SimpleDenseMat](#_CPPv4I0EN2ML14SimpleDenseMatE)<[T](#_CPPv4I0EN2ML14SimpleDenseMatE)> &A, const bool transA, const bool transB, const [T](#_CPPv4I0EN2ML14SimpleDenseMatE) beta, [SimpleDenseMat](#_CPPv4I0EN2ML14SimpleDenseMatE)<[T](#_CPPv4I0EN2ML14SimpleDenseMatE)> &C, cudaStream_t stream) const override

GEMM assigning to C where `this` refers to B.

```default
C <- alpha * A^transA * (*this)^transB + beta * C
```

### inline void assign_gemm(const raft::handle_t &handle, const [T](#_CPPv4I0EN2ML14SimpleDenseMatE) alpha, const [SimpleDenseMat](#_CPPv4I0EN2ML14SimpleDenseMatE)<[T](#_CPPv4I0EN2ML14SimpleDenseMatE)> &A, const bool transA, const [SimpleMat](#_CPPv4I0EN2ML9SimpleMatE)<[T](#_CPPv4I0EN2ML14SimpleDenseMatE)> &B, const bool transB, const [T](#_CPPv4I0EN2ML14SimpleDenseMatE) beta, cudaStream_t stream)

GEMM assigning to C where `this` refers to C.

```default
*this <- alpha * A^transA * B^transB + beta * (*this)
```

### template<typename T>struct SimpleMat

 *#include <base.hpp>*

Subclassed by [ML::SimpleDenseMat< T >](#structML_1_1SimpleDenseMat), [ML::SimpleSparseMat< T, I >](#structML_1_1SimpleSparseMat)

### Public Functions

### virtual void gemmb(const raft::handle_t &handle, const [T](#_CPPv4I0EN2ML9SimpleMatE) alpha, const [SimpleDenseMat](#_CPPv4I0EN2ML14SimpleDenseMatE)<[T](#_CPPv4I0EN2ML9SimpleMatE)> &A, const bool transA, const bool transB, const [T](#_CPPv4I0EN2ML9SimpleMatE) beta, [SimpleDenseMat](#_CPPv4I0EN2ML14SimpleDenseMatE)<[T](#_CPPv4I0EN2ML9SimpleMatE)> &C, cudaStream_t stream) const = 0

GEMM assigning to C where `this` refers to B.

```default
C <- alpha * A^transA * (*this)^transB + beta * C
```

### template<typename T>struct SimpleMatOwning : public [ML](#_CPPv42ML)::[SimpleDenseMat](#_CPPv4I0EN2ML14SimpleDenseMatE)<[T](#_CPPv4I0EN2ML15SimpleMatOwningE)>

 *#include <dense.hpp>*

### template<typename T, typename I = int>struct SimpleSparseMat : public [ML](#_CPPv42ML)::[SimpleMat](#_CPPv4I0EN2ML9SimpleMatE)<[T](#_CPPv4I00EN2ML15SimpleSparseMatE)>

 *#include <sparse.hpp>*

[Sparse](#namespaceML_1_1Sparse) matrix in CSR format.

Note, we use cuSPARSE to manimulate matrices, and it guarantees:

1. row_ids[m] == nnz
2. cols are sorted within rows.

However, when the data comes from the outside, we cannot guarantee that. 

### Public Functions

### inline virtual void gemmb(const raft::handle_t &handle, const [T](#_CPPv4I00EN2ML15SimpleSparseMatE) alpha, const [SimpleDenseMat](#_CPPv4I0EN2ML14SimpleDenseMatE)<[T](#_CPPv4I00EN2ML15SimpleSparseMatE)> &A, const bool transA, const bool transB, const [T](#_CPPv4I00EN2ML15SimpleSparseMatE) beta, [SimpleDenseMat](#_CPPv4I0EN2ML14SimpleDenseMatE)<[T](#_CPPv4I00EN2ML15SimpleSparseMatE)> &C, cudaStream_t stream) const override

GEMM assigning to C where `this` refers to B.

```default
C <- alpha * A^transA * (*this)^transB + beta * C
```

### template<typename T>struct SimpleVec : public [ML](#_CPPv42ML)::[SimpleDenseMat](#_CPPv4I0EN2ML14SimpleDenseMatE)<[T](#_CPPv4I0EN2ML9SimpleVecE)>

 *#include <dense.hpp>*

Subclassed by [ML::SimpleVecOwning< T >](#structML_1_1SimpleVecOwning)

### template<typename T>struct SimpleVecOwning : public [ML](#_CPPv42ML)::[SimpleVec](#_CPPv4I0EN2ML9SimpleVecE)<[T](#_CPPv4I0EN2ML15SimpleVecOwningE)>

 *#include <dense.hpp>*

### struct TSNEParams

 *#include <tsne.h>*

### class UMAPParams

 *#include <umapparams.h>*

### Public Members

### int n_neighbors = 15

The number of neighbors to use to approximate geodesic distance. Larger numbers induce more global estimates of the manifold that can miss finer detail, while smaller values will focus on fine manifold structure to the detriment of the larger picture. 

### int n_components = 2

Number of features in the final embedding 

### int n_epochs = 0

Number of epochs to use in the training of the embedding. 

### float learning_rate = 1.0

Initial learning rate for the embedding optimization 

### float min_dist = 0.1

The effective minimum distance between embedded points. Smaller values will result in a more clustered/clumped embedding where nearby points on the manifold are drawn closer together, while larger values will result on a more even dispersal of points. The value should be set relative to the `[spread](#classML_1_1UMAPParams_1a50efd712da02cf276bb75e9a3f613948)` value, which determines the scale at which embedded points will be spread out. 

### float spread = 1.0

The effective scale of embedded points. In combination with `[min_dist](#classML_1_1UMAPParams_1a281f4a7eb2a5c9c62054adb3b9036dc8)` this determines how clustered/clumped the embedded points are. 

### float set_op_mix_ratio = 1.0

Interpolate between (fuzzy) union and intersection as the set operation used to combine local fuzzy simplicial sets to obtain a global fuzzy simplicial sets. Both fuzzy set operations use the product t-norm. The value of this parameter should be between 0.0 and 1.0; a value of 1.0 will use a pure fuzzy union, while 0.0 will use a pure fuzzy intersection. 

### float local_connectivity = 1.0

The local connectivity required – i.e. the number of nearest neighbors that should be assumed to be connected at a local level. The higher this value the more connected the manifold becomes locally. In practice this should be not more than the local intrinsic dimension of the manifold. 

### float repulsion_strength = 1.0

Weighting applied to negative samples in low dimensional embedding optimization. Values higher than one will result in greater weight being given to negative samples. 

### int negative_sample_rate = 5

The number of negative samples to select per positive sample in the optimization process. Increasing this value will result in greater repulsive force being applied, greater optimization cost, but slightly more accuracy. 

### float transform_queue_size = 4.0

For transform operations (embedding new points using a trained model_ this will control how aggressively to search for nearest neighbors. Larger values will result in slower performance but more accurate nearest neighbor evaluation. 

### rapids_logger::level_enum verbosity = rapids_logger::level_enum::info

Control logging level during algorithm execution 

### float a = -1.0

More specific parameters controlling the embedding. If None these values are set automatically as determined by `[min_dist](#classML_1_1UMAPParams_1a281f4a7eb2a5c9c62054adb3b9036dc8)` and `[spread](#classML_1_1UMAPParams_1a50efd712da02cf276bb75e9a3f613948)`. 

### float b = -1.0

More specific parameters controlling the embedding. If None these values are set automatically as determined by `[min_dist](#classML_1_1UMAPParams_1a281f4a7eb2a5c9c62054adb3b9036dc8)` and `[spread](#classML_1_1UMAPParams_1a50efd712da02cf276bb75e9a3f613948)`. 

### float initial_alpha = 1.0

Initial learning rate for SGD 

### int init = 1

Embedding initializer algorithm 0 = random layout 1 = spectral layout 

### graph_build_algo build_algo = graph_build_algo::BRUTE_FORCE_KNN

[KNN](#namespaceML_1_1KNN) graph build algorithm 

### int target_n_neighbors = -1

The number of nearest neighbors to use to construct the target simplicial set. If set to -1, use the n_neighbors value. 

### bool force_serial_epochs = false

If true, optimization epochs will be executed with reduced GPU parallelism. This is commonly useful for deterministic runs with random_state set, and may also be enabled to avoid outliers for spectral initialization. This may slow the optimization step. Use this to resolve rare edge cases where the default heuristics do not trigger. 

### bool deterministic = true

Whether should we use deterministic algorithm. This should be set to true if random_state is provided, otherwise it’s false. When it’s true, cuml will have higher memory usage but produce stable numeric output. 

### namespace CD

### namespace opg

### Functions

### int fit(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> &labels, float \*coef, float \*intercept, bool fit_intercept, int epochs, float alpha, float l1_ratio, bool shuffle, float tol, bool verbose)

performs MNMG coordinate descent fit (elastic net / lasso) 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **input_data** – **[in]** vector holding all partitions for that rank 
  * **input_desc** – **[in]** PartDescriptor object for the input 
  * **labels** – **[in]** labels data 
  * **coef** – **[out]** learned regression coefficients 
  * **intercept** – **[out]** intercept value 
  * **fit_intercept** – **[in]** fit intercept or not 
  * **epochs** – **[in]** number of epochs 
  * **alpha** – **[in]** regularization strength 
  * **l1_ratio** – **[in]** l1 ratio 
  * **shuffle** – **[in]** whether to shuffle the data 
  * **tol** – **[in]** tolerance for early stopping during fitting 
  * **verbose** – **[in]** 
* **Returns:**
  n_iter: the number of solver iterations run 

### int fit(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double>\*> &labels, double \*coef, double \*intercept, bool fit_intercept, int epochs, double alpha, double l1_ratio, bool shuffle, double tol, bool verbose)

### void predict(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, size_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*input, size_t n_rows, size_t n_cols, float \*coef, float intercept, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*preds, bool verbose)

performs MNMG prediction for coordinate descent models 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **rank_sizes** – **[in]** includes all the partition size information for the rank 
  * **n_parts** – **[in]** number of partitions 
  * **input** – **[in]** input data 
  * **n_rows** – **[in]** number of rows of input data 
  * **n_cols** – **[in]** number of cols of input data 
  * **coef** – **[in]** learned regression coefficients 
  * **intercept** – **[in]** the fit intercept 
  * **preds** – **[out]** predictions 
  * **verbose** – **[in]** 

### void predict(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, size_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*input, size_t n_rows, size_t n_cols, double \*coef, double intercept, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*preds, bool verbose)

### namespace Datasets

### Functions

### void make_regression(const raft::handle_t &handle, float \*out, float \*values, int64_t n_rows, int64_t n_cols, int64_t n_informative, float \*coef = nullptr, int64_t n_targets = 1LL, float bias = 0.0f, int64_t effective_rank = -1LL, float tail_strength = 0.5f, float noise = 0.0f, bool shuffle = true, uint64_t seed = 0ULL)

GPU-equivalent of sklearn.datasets.make_regression as documented at: [https://scikit-learn.org/stable/modules/generated/sklearn.datasets.make_regression.html](https://scikit-learn.org/stable/modules/generated/sklearn.datasets.make_regression.html). 

* **Parameters:**
  * **handle** – **[in]** cuML handle 
  * **out** – **[out]** Row-major (samples, features) matrix to store the problem data 
  * **values** – **[out]** Row-major (samples, targets) matrix to store the values for the regression problem 
  * **n_rows** – **[in]** Number of samples 
  * **n_cols** – **[in]** Number of features 
  * **n_informative** – **[in]** Number of informative features (non-zero coefficients) 
  * **coef** – **[out]** Row-major (features, targets) matrix to store the coefficients used to generate the values for the regression problem. If nullptr is given, nothing will be written 
  * **n_targets** – **[in]** Number of targets (generated values per sample) 
  * **bias** – **[in]** A scalar that will be added to the values 
  * **effective_rank** – **[in]** The approximate rank of the data matrix (used to create correlations in the data). -1 is the code to use well-conditioned data 
  * **tail_strength** – **[in]** The relative importance of the fat noisy tail of the singular values profile if effective_rank is not -1 
  * **noise** – **[in]** Standard deviation of the gaussian noise applied to the output 
  * **shuffle** – **[in]** Shuffle the samples and the features 
  * **seed** – **[in]** Seed for the random number generator 

### void make_regression(const raft::handle_t &handle, double \*out, double \*values, int64_t n_rows, int64_t n_cols, int64_t n_informative, double \*coef = nullptr, int64_t n_targets = 1LL, double bias = 0.0, int64_t effective_rank = -1LL, double tail_strength = 0.5, double noise = 0.0, bool shuffle = true, uint64_t seed = 0ULL)

### void make_regression(const raft::handle_t &handle, float \*out, float \*values, int n_rows, int n_cols, int n_informative, float \*coef = nullptr, int n_targets = 1LL, float bias = 0.0f, int effective_rank = -1LL, float tail_strength = 0.5f, float noise = 0.0f, bool shuffle = true, uint64_t seed = 0ULL)

### void make_regression(const raft::handle_t &handle, double \*out, double \*values, int n_rows, int n_cols, int n_informative, double \*coef = nullptr, int n_targets = 1LL, double bias = 0.0, int effective_rank = -1LL, double tail_strength = 0.5, double noise = 0.0, bool shuffle = true, uint64_t seed = 0ULL)

### namespace Dbscan

### Enums

### enum EpsNnMethod

*Values:*

### enumerator BRUTE_FORCE

### enumerator RBC

### namespace AdjGraph

### template<typename Index_ = int>struct Pack

 *#include <pack.h>*

### Public Members

### [Index_](#_CPPv4I0EN2ML6Dbscan8AdjGraph4PackE) \*vd

vertex degree array Last position is the sum of all elements in this array (excluding it) Hence, its length is one more than the number of poTypes 

### bool \*adj

the adjacency matrix 

### [Index_](#_CPPv4I0EN2ML6Dbscan8AdjGraph4PackE) \*adj_graph

the adjacency graph 

### [Index_](#_CPPv4I0EN2ML6Dbscan8AdjGraph4PackE) \*ex_scan

exculusive scan generated from vd 

### [Index_](#_CPPv4I0EN2ML6Dbscan8AdjGraph4PackE) N

number of points in the dataset 

### namespace VertexDeg

### template<typename Type, typename Index_>struct Pack

 *#include <pack.h>*

### Public Functions

### inline void resetArray(cudaStream_t stream, [Index_](#_CPPv4I00EN2ML6Dbscan9VertexDeg4PackE) vdlen)

reset the output array before calling the actual kernel 

* **Parameters:**
  * **stream** – cuda stream where to perform this operation 
  * **vdlen** – length of the vertex degree array 

### Public Members

### void \*rbc_index

optional rbc index 

### [Index_](#_CPPv4I00EN2ML6Dbscan9VertexDeg4PackE) \*vd

vertex degree array Last position is the sum of all elements in this array (excluding it) Hence, its length is one more than the number of points 

### [Type](#_CPPv4I00EN2ML6Dbscan9VertexDeg4PackE) \*weight_sum

weighted vertex degree 

### [Index_](#_CPPv4I00EN2ML6Dbscan9VertexDeg4PackE) \*ia

the CSR adjacency matrix 

### [Index_](#_CPPv4I00EN2ML6Dbscan9VertexDeg4PackE) max_k

iff > 0 maximum expected rowlength 

### bool \*adj

the dense adjacency matrix 

### const [Type](#_CPPv4I00EN2ML6Dbscan9VertexDeg4PackE) \*x

input dataset 

### const [Type](#_CPPv4I00EN2ML6Dbscan9VertexDeg4PackE) \*sample_weight

weighted vertex degree 

### [Type](#_CPPv4I00EN2ML6Dbscan9VertexDeg4PackE) eps

epsilon neighborhood thresholding param 

### [Index_](#_CPPv4I00EN2ML6Dbscan9VertexDeg4PackE) N

number of points in the dataset 

### [Index_](#_CPPv4I00EN2ML6Dbscan9VertexDeg4PackE) D

dataset dimensionality 

### namespace detail

### Functions

### template<checked_target T, checked_source U>constexpr [T](#_CPPv4I_14checked_target_14checked_sourceEN2ML6detail13widen_or_failE1T1UPKc) widen_or_fail([U](#_CPPv4I_14checked_target_14checked_sourceEN2ML6detail13widen_or_failE1T1UPKc) value, char const \*op)

Widen `value` to `T`, trapping if the source value cannot be represented in `T`. 

### template<checked_target T>constexpr [T](#_CPPv4I_14checked_targetEN2ML6detail16checked_mul_pairE1T1T1T) checked_mul_pair([T](#_CPPv4I_14checked_targetEN2ML6detail16checked_mul_pairE1T1T1T) a, [T](#_CPPv4I_14checked_targetEN2ML6detail16checked_mul_pairE1T1T1T) b)

### template<checked_target T>constexpr [T](#_CPPv4I_14checked_targetEN2ML6detail16checked_add_pairE1T1T1T) checked_add_pair([T](#_CPPv4I_14checked_targetEN2ML6detail16checked_add_pairE1T1T1T) a, [T](#_CPPv4I_14checked_targetEN2ML6detail16checked_add_pairE1T1T1T) b)

### inline void cuml_rf_allreduce_validation_status(const raft::handle_t &handle, const int \*local_status, int \*global_status)

### inline void cuml_rf_allreduce_oob_stats(const raft::handle_t &handle, const double \*local_stats, double \*global_stats, std::size_t count)

### namespace distance

### Enums

### enum class DistanceType

*Values:*

### enumerator L2Expanded

### enumerator L2SqrtExpanded

### enumerator CosineExpanded

### enumerator L1

### enumerator L2Unexpanded

### enumerator L2SqrtUnexpanded

### enumerator InnerProduct

### enumerator Linf

### enumerator Canberra

### enumerator LpUnexpanded

### enumerator CorrelationExpanded

### enumerator JaccardExpanded

### enumerator HellingerExpanded

### enumerator Haversine

### enumerator BrayCurtis

### enumerator JensenShannon

### enumerator HammingUnexpanded

### enumerator KLDivergence

### enumerator RusselRaoExpanded

### enumerator DiceExpanded

### enumerator BitwiseHamming

### enumerator Precomputed

### namespace DT

### Typedefs

### typedef [TreeMetaDataNode](#_CPPv4I00EN2ML2DT16TreeMetaDataNodeE)<float, int> TreeClassifierF

### typedef [TreeMetaDataNode](#_CPPv4I00EN2ML2DT16TreeMetaDataNodeE)<double, int> TreeClassifierD

### typedef [TreeMetaDataNode](#_CPPv4I00EN2ML2DT16TreeMetaDataNodeE)<float, float> TreeRegressorF

### typedef [TreeMetaDataNode](#_CPPv4I00EN2ML2DT16TreeMetaDataNodeE)<double, double> TreeRegressorD

### Functions

### void set_tree_params([DecisionTreeParams](#_CPPv4N2ML2DT18DecisionTreeParamsE) &params, int cfg_max_depth = -1, int cfg_max_leaves = -1, float cfg_max_features = 1.0f, int cfg_max_n_bins = 128, int cfg_min_samples_leaf = 1, int cfg_min_samples_split = 2, float cfg_min_impurity_decrease = 0.0f, [CRITERION](#_CPPv4N2ML9CRITERIONE) cfg_split_criterion = CRITERION_END, int cfg_max_batch_size = 4096)

Set all [DecisionTreeParams](#structML_1_1DT_1_1DecisionTreeParams) members. 

* **Parameters:**
  * **params** – **[inout]** update with tree parameters 
  * **cfg_max_depth** – **[in]** maximum tree depth; default -1 
  * **cfg_max_leaves** – **[in]** maximum leaves; default -1 
  * **cfg_max_features** – **[in]** maximum number of features; default 1.0f 
  * **cfg_max_n_bins** – **[in]** maximum number of bins; default 128 
  * **cfg_min_samples_leaf** – **[in]** min. rows in each leaf node; default 1 
  * **cfg_min_samples_split** – **[in]** min. rows needed to split an internal node; default 2 
  * **cfg_min_impurity_decrease** – **[in]** split a node only if its weighted impurity decrease exceeds this value 
  * **cfg_split_criterion** – **[in]** split criterion; default CRITERION_END, i.e., GINI for classification or MSE for regression 
  * **cfg_max_batch_size** – **[in]** Maximum number of nodes that can be processed in a batch. This is used only for batched-level algo. Default value 4096. 

### template<class T, class L>std::string get_tree_summary_text(const [TreeMetaDataNode](#_CPPv4I00EN2ML2DT16TreeMetaDataNodeE)<[T](#_CPPv4I00EN2ML2DT21get_tree_summary_textENSt6stringEPK16TreeMetaDataNodeI1T1LE), [L](#_CPPv4I00EN2ML2DT21get_tree_summary_textENSt6stringEPK16TreeMetaDataNodeI1T1LE)> \*tree)

Obtain high-level tree information. 

* **Template Parameters:**
  * **T** – data type for input data (float or double). 
  * **L** – data type for labels (int type for classification, T type for regression). 
* **Parameters:**
  **tree** – **[in]** CPU pointer to [TreeMetaDataNode](#structML_1_1DT_1_1TreeMetaDataNode)
* **Returns:**
  High-level tree information as string 

### template<class T, class L>std::string get_tree_text(const [TreeMetaDataNode](#_CPPv4I00EN2ML2DT16TreeMetaDataNodeE)<[T](#_CPPv4I00EN2ML2DT13get_tree_textENSt6stringEPK16TreeMetaDataNodeI1T1LE), [L](#_CPPv4I00EN2ML2DT13get_tree_textENSt6stringEPK16TreeMetaDataNodeI1T1LE)> \*tree)

Obtain detailed tree information. 

* **Template Parameters:**
  * **T** – data type for input data (float or double). 
  * **L** – data type for labels (int type for classification, T type for regression). 
* **Parameters:**
  **tree** – **[in]** CPU pointer to [TreeMetaDataNode](#structML_1_1DT_1_1TreeMetaDataNode)
* **Returns:**
  Detailed tree information as string 

### template<class T, class L>std::string get_tree_json(const [TreeMetaDataNode](#_CPPv4I00EN2ML2DT16TreeMetaDataNodeE)<[T](#_CPPv4I00EN2ML2DT13get_tree_jsonENSt6stringEPK16TreeMetaDataNodeI1T1LE), [L](#_CPPv4I00EN2ML2DT13get_tree_jsonENSt6stringEPK16TreeMetaDataNodeI1T1LE)> \*tree)

Export tree as a JSON string. 

* **Template Parameters:**
  * **T** – data type for input data (float or double). 
  * **L** – data type for labels (int type for classification, T type for regression). 
* **Parameters:**
  **tree** – **[in]** CPU pointer to [TreeMetaDataNode](#structML_1_1DT_1_1TreeMetaDataNode)
* **Returns:**
  Tree structure as JSON stsring 

### template<typename DataT, typename LabelT>struct Dataset

 *#include <dataset.h>*

### Public Members

### const [DataT](#_CPPv4I00EN2ML2DT7DatasetE) \*data

input dataset 

### const [LabelT](#_CPPv4I00EN2ML2DT7DatasetE) \*labels

input labels 

### const double \*sample_weight

optional input sample weights 

### std::int64_t n_rows

total rows in dataset 

### std::int64_t n_cols

total cols in dataset 

### std::int64_t row_stride

row stride in input data elements 

### std::int64_t col_stride

column stride in input data elements 

### std::int64_t n_sampled_rows

total sampled rows in dataset 

### std::int64_t n_sampled_cols

total sampled cols in dataset 

### std::int64_t \*row_ids

indices of sampled rows 

### int num_outputs

Number of classes or regression outputs 

### struct DecisionTreeParams

 *#include <decisiontree.hpp>*

### Public Members

### int max_depth

Maximum tree depth. Set to INT32_MAX for unlimited depth (i.e., until leaves are pure or other stopping criteria are met). 

### int max_leaves

Maximum leaf nodes per tree. Soft constraint. Unlimited, If `-1`. 

### float max_features

Ratio of number of features (columns) to consider per node split. 

### int max_n_bins

maximum number of bins used by the split algorithm per feature. 

### int min_samples_leaf

The minimum number of samples (rows) in each leaf node. 

### int min_samples_split

The minimum number of samples (rows) needed to split an internal node. 

### [CRITERION](#_CPPv4N2ML9CRITERIONE) split_criterion

Node split criterion. GINI and Entropy for classification, MSE for regression. 

### float min_impurity_decrease = 0.0f

A node is split if its weighted impurity decrease exceeds this value. Default is 0.0. 

### int max_batch_size

Maximum number of nodes that can be processed in a given batch. This is used only for batched-level algo 

### template<typename DataT>struct Quantiles

 *#include <quantiles.h>*

### Public Members

### [DataT](#_CPPv4I0EN2ML2DT9QuantilesE) \*quantiles_array

quantiles computed for each feature of dataset in col-major 

### int \*n_bins_array

The number of bins used for quantiles of each feature 

### template<typename T>class TreeliteType

### template<>class TreeliteType<double>

 *#include <treelite_util.h>*

### template<>class TreeliteType<float>

 *#include <treelite_util.h>*

### template<>class TreeliteType<int>

 *#include <treelite_util.h>*

### template<>class TreeliteType<uint32_t>

 *#include <treelite_util.h>*

### template<class T, class L>struct TreeMetaDataNode

 *#include <decisiontree.hpp>*

### namespace Explainer

### Typedefs

### using TreePathHandle = std::variant<std::shared_ptr<[TreePathInfo](#_CPPv4I0EN2ML9Explainer12TreePathInfoE)<float>>, std::shared_ptr<[TreePathInfo](#_CPPv4I0EN2ML9Explainer12TreePathInfoE)<double>>>

### using FloatPointer = std::variant<float\*, double\*>

### Functions

### void kernel_dataset(const raft::handle_t &handle, float \*X, int nrows_X, int ncols, float \*background, int nrows_background, float \*dataset, float \*observation, int \*nsamples, int len_nsamples, int maxsample, uint64_t seed = 0ULL)

Generates samples of dataset for kernel shap algorithm.


Kernel distributes exact part of the kernel shap dataset Each block scatters the data of a row of `observations` into the (number of rows of background) in `dataset`, based on the row of `X`. So, given: background = [[0, 1, 2], [3, 4, 5]] observation = [100, 101, 102] X = [[1, 0, 1], [0, 1, 1]]

dataset (output): [[100, 1, 102], [100, 4, 102] [0, 101, 102], [3, 101, 102]] The first thread of each block calculates the sampling of `k` entries of `observation` to scatter into `dataset`. Afterwards each block scatters the data of a row of `X` into the (number of rows of background) in `dataset`. So, given: background = [[0, 1, 2, 3], [5, 6, 7, 8]] observation = [100, 101, 102, 103] nsamples = [3, 2]

X (output) [[1, 0, 1, 1], [0, 1, 1, 0]]

dataset (output): [[100, 1, 102, 103], [100, 6, 102, 103] [0, 101, 102, 3], [5, 101, 102, 8]] 

* **Parameters:**
  * **handle** – **[in]** cuML handle 
  * **X** – **[inout]** generated data [on device] 1-0 (row major) 
  * **nrows_X** – **[in]** number of rows in X 
  * **ncols** – **[in]** number of columns in X, background and dataset 
  * **background** – **[in]** background data [on device] 
  * **nrows_background** – **[in]** number of rows in background dataset 
  * **dataset** – **[out]** generated data [on device] observation=background (row major) 
  * **observation** – **[in]** row to scatter 
  * **nsamples** – **[in]** vector with number of entries that are randomly sampled 
  * **len_nsamples** – **[in]** number of entries to be sampled 
  * **maxsample** – **[in]** size of the biggest sampled observation 
  * **seed** – **[in]** Seed for the random number generator

### void permutation_shap_dataset(const raft::handle_t &handle, float \*dataset, const float \*background, int nrows_bg, int ncols, const float \*row, int \*idx, bool row_major)

Generates a dataset by tiling the `background` matrix into `out`, while adding a forward and backward permutation pass of the observation `row` on the positions defined by `idx`. Example:

background = [[0, 1, 2], [3, 4, 5], [6, 7, 8]] idx = [2, 0, 1] row = [100, 101, 102] output: [[ 0, 1, 2] [ 3, 4, 5] [ 6, 7, 8] [ 0, 1, 102] [ 3, 4, 102] [ 6, 7, 102] [100, 1, 102] [100, 4, 102] [100, 7, 102] [100, 101, 102] [100, 101, 102] [100, 101, 102] [100, 101, 2] [100, 101, 5] [100, 101, 8] [ 0, 101, 2] [ 3, 101, 5] [ 6, 101, 8] [ 0, 1, 2] [ 3, 4, 5] [ 6, 7, 8]]

* **Parameters:**
  * **handle** – **[in]** cuML handle 
  * **dataset** – **[out]** generated data in either row major or column major format, depending on the `row_major` parameter [on device] [dim = (2 \* ncols \* nrows_bg + nrows_bg) \* ncols] 
  * **background** – **[in]** background data [on device] [dim = ncols \* nrows_bg] 
  * **nrows_bg** – **[in]** number of rows in background dataset 
  * **ncols** – **[in]** number of columns 
  * **row** – **[in]** row to scatter in a permutated fashion [dim = ncols] 
  * **idx** – **[in]** permutation indexes [dim = ncols] 
  * **row_major** – **[in]** boolean to generate either row or column major data 

### void shap_main_effect_dataset(const raft::handle_t &handle, float \*dataset, const float \*background, int nrows_bg, int ncols, const float \*row, int \*idx, bool row_major)

Generates a dataset by tiling the `background` matrix into `out`, while adding a forward and backward permutation pass of the observation `row` on the positions defined by `idx`. Example:

background = [[0, 1, 2], [3, 4, 5], [6, 7, 8]] idx = [2, 0, 1] row = [100, 101, 102] output: [[ 0, 1, 2] [ 3, 4, 5] [ 6, 7, 8] [ 0, 1, 102] [ 3, 4, 102] [ 6, 7, 102] [100, 1, 2] [100, 4, 5] [100, 7, 8] [ 0, 101, 2] [ 3, 101, 5] [ 6, 101, 8]]

* **Parameters:**
  * **handle** – **[in]** cuML handle 
  * **dataset** – **[out]** generated data [on device] [dim = (2 \* ncols \* nrows_bg + nrows_bg) \* ncols] 
  * **background** – **[in]** background data [on device] [dim = ncols \* nrows_bg] 
  * **nrows_bg** – **[in]** number of rows in background dataset 
  * **ncols** – **[in]** number of columns 
  * **row** – **[in]** row to scatter in a permutated fashion [dim = ncols] 
  * **idx** – **[in]** permutation indexes [dim = ncols] 
  * **row_major** – **[in]** boolean to generate either row or column major data 

### void update_perm_shap_values(const raft::handle_t &handle, float \*shap_values, const float \*y_hat, const int ncols, const int \*idx)

Function that aggregates averages of the averatge of results of the model called with the permutation dataset, to estimate the SHAP values. It is equivalent to the Python code: for i,ind in enumerate(idx): shap_values[ind] += y_hat[i + 1] - y_hat[i] for i,ind in enumerate(idx): shap_values[ind] += y_hat[i + ncols] - y_hat[i + ncols + 1]

* **Parameters:**
  * **handle** – **[in]** cuML handle 
  * **shap_values** – **[out]** Array where the results are aggregated [dim = ncols] 
  * **y_hat** – **[in]** Results to use for the aggregation [dim = ncols + 1] 
  * **ncols** – **[in]** number of columns 
  * **idx** – **[in]** permutation indexes [dim = ncols] 

### [TreePathHandle](#_CPPv4N2ML9Explainer14TreePathHandleE) extract_path_info(TreeliteModelHandle model)

### void gpu_treeshap([TreePathHandle](#_CPPv4N2ML9Explainer14TreePathHandleE) path_info, const [FloatPointer](#_CPPv4N2ML9Explainer12FloatPointerE) data, std::size_t n_rows, std::size_t n_cols, [FloatPointer](#_CPPv4N2ML9Explainer12FloatPointerE) out_preds, std::size_t out_preds_size)

### void gpu_treeshap_interventional([TreePathHandle](#_CPPv4N2ML9Explainer14TreePathHandleE) path_info, const [FloatPointer](#_CPPv4N2ML9Explainer12FloatPointerE) data, std::size_t n_rows, std::size_t n_cols, const [FloatPointer](#_CPPv4N2ML9Explainer12FloatPointerE) background_data, std::size_t background_n_rows, std::size_t background_n_cols, [FloatPointer](#_CPPv4N2ML9Explainer12FloatPointerE) out_preds, std::size_t out_preds_size)

### void gpu_treeshap_interactions([TreePathHandle](#_CPPv4N2ML9Explainer14TreePathHandleE) path_info, const [FloatPointer](#_CPPv4N2ML9Explainer12FloatPointerE) data, std::size_t n_rows, std::size_t n_cols, [FloatPointer](#_CPPv4N2ML9Explainer12FloatPointerE) out_preds, std::size_t out_preds_size)

### void gpu_treeshap_taylor_interactions([TreePathHandle](#_CPPv4N2ML9Explainer14TreePathHandleE) path_info, const [FloatPointer](#_CPPv4N2ML9Explainer12FloatPointerE) data, std::size_t n_rows, std::size_t n_cols, [FloatPointer](#_CPPv4N2ML9Explainer12FloatPointerE) out_preds, std::size_t out_preds_size)

### template<typename T>class TreePathInfo

### namespace GLM

### Functions

### template<typename T, typename I = int>void qnFit(const raft::handle_t &cuml_handle, const qn_params &params, [T](#_CPPv4I00EN2ML3GLM5qnFitEvRKN4raft8handle_tERK9qn_paramsP1TbP1T1I1I1IP1TP1TPiP1T1T) \*X, bool X_col_major, [T](#_CPPv4I00EN2ML3GLM5qnFitEvRKN4raft8handle_tERK9qn_paramsP1TbP1T1I1I1IP1TP1TPiP1T1T) \*y, [I](#_CPPv4I00EN2ML3GLM5qnFitEvRKN4raft8handle_tERK9qn_paramsP1TbP1T1I1I1IP1TP1TPiP1T1T) N, [I](#_CPPv4I00EN2ML3GLM5qnFitEvRKN4raft8handle_tERK9qn_paramsP1TbP1T1I1I1IP1TP1TPiP1T1T) D, [I](#_CPPv4I00EN2ML3GLM5qnFitEvRKN4raft8handle_tERK9qn_paramsP1TbP1T1I1I1IP1TP1TPiP1T1T) C, [T](#_CPPv4I00EN2ML3GLM5qnFitEvRKN4raft8handle_tERK9qn_paramsP1TbP1T1I1I1IP1TP1TPiP1T1T) \*w0, [T](#_CPPv4I00EN2ML3GLM5qnFitEvRKN4raft8handle_tERK9qn_paramsP1TbP1T1I1I1IP1TP1TPiP1T1T) \*f, int \*num_iters, [T](#_CPPv4I00EN2ML3GLM5qnFitEvRKN4raft8handle_tERK9qn_paramsP1TbP1T1I1I1IP1TP1TPiP1T1T) \*sample_weight = nullptr, [T](#_CPPv4I00EN2ML3GLM5qnFitEvRKN4raft8handle_tERK9qn_paramsP1TbP1T1I1I1IP1TP1TPiP1T1T) svr_eps = 0)

Fit a [GLM](#namespaceML_1_1GLM) using quasi newton methods. 

* **Parameters:**
  * **cuml_handle** – reference to raft::handle_t object 
  * **params** – model parameters 
  * **X** – device pointer to a contiguous feature matrix of dimension [N, D] 
  * **X_col_major** – true if X is stored column-major 
  * **y** – device pointer to label vector of length N 
  * **N** – number of examples 
  * **D** – number of features 
  * **C** – number of outputs (number of classes or `1` for regression) 
  * **w0** – device pointer of size (D + (fit_intercept ? 1 : 0)) \* C with initial point, overwritten by final result. 
  * **f** – host pointer holding the final objective value 
  * **num_iters** – host pointer holding the actual number of iterations taken 
  * **sample_weight** – device pointer to sample weight vector of length n_rows (nullptr for uniform weights) 
  * **svr_eps** – epsilon parameter for svr 

### template<typename T, typename I = int>void qnFitSparse(const raft::handle_t &cuml_handle, const qn_params &params, [T](#_CPPv4I00EN2ML3GLM11qnFitSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1IP1T1I1I1IP1TP1TPiP1T1T) \*X_values, [I](#_CPPv4I00EN2ML3GLM11qnFitSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1IP1T1I1I1IP1TP1TPiP1T1T) \*X_cols, [I](#_CPPv4I00EN2ML3GLM11qnFitSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1IP1T1I1I1IP1TP1TPiP1T1T) \*X_row_ids, [I](#_CPPv4I00EN2ML3GLM11qnFitSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1IP1T1I1I1IP1TP1TPiP1T1T) X_nnz, [T](#_CPPv4I00EN2ML3GLM11qnFitSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1IP1T1I1I1IP1TP1TPiP1T1T) \*y, [I](#_CPPv4I00EN2ML3GLM11qnFitSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1IP1T1I1I1IP1TP1TPiP1T1T) N, [I](#_CPPv4I00EN2ML3GLM11qnFitSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1IP1T1I1I1IP1TP1TPiP1T1T) D, [I](#_CPPv4I00EN2ML3GLM11qnFitSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1IP1T1I1I1IP1TP1TPiP1T1T) C, [T](#_CPPv4I00EN2ML3GLM11qnFitSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1IP1T1I1I1IP1TP1TPiP1T1T) \*w0, [T](#_CPPv4I00EN2ML3GLM11qnFitSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1IP1T1I1I1IP1TP1TPiP1T1T) \*f, int \*num_iters, [T](#_CPPv4I00EN2ML3GLM11qnFitSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1IP1T1I1I1IP1TP1TPiP1T1T) \*sample_weight = nullptr, [T](#_CPPv4I00EN2ML3GLM11qnFitSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1IP1T1I1I1IP1TP1TPiP1T1T) svr_eps = 0)

Fit a [GLM](#namespaceML_1_1GLM) using quasi newton methods. 

* **Parameters:**
  * **cuml_handle** – reference to raft::handle_t object 
  * **params** – model parameters 
  * **X_values** – feature matrix values (CSR format), length = X_nnz 
  * **X_cols** – feature matrix columns (CSR format), length = X_nnz, range = [0, … D-1] 
  * **X_row_ids** – feature matrix compressed row ids (CSR format), length = N + 1, range = [0, … X_nnz] 
  * **X_nnz** – number of non-zero entries in the feature matrix (CSR format) 
  * **y** – device pointer to label vector of length N 
  * **N** – number of examples 
  * **D** – number of features 
  * **C** – number of outputs (number of classes or `1` for regression) 
  * **w0** – device pointer of size (D + (fit_intercept ? 1 : 0)) \* C with initial point, overwritten by final result. 
  * **f** – host pointer holding the final objective value 
  * **num_iters** – host pointer holding the actual number of iterations taken 
  * **sample_weight** – device pointer to sample weight vector of length n_rows (nullptr for uniform weights) 
  * **svr_eps** – epsilon parameter for svr 

### template<typename T, typename I = int>void qnDecisionFunction(const raft::handle_t &cuml_handle, const qn_params &params, [T](#_CPPv4I00EN2ML3GLM18qnDecisionFunctionEvRKN4raft8handle_tERK9qn_paramsP1Tb1I1I1IP1TP1T) \*X, bool X_col_major, [I](#_CPPv4I00EN2ML3GLM18qnDecisionFunctionEvRKN4raft8handle_tERK9qn_paramsP1Tb1I1I1IP1TP1T) N, [I](#_CPPv4I00EN2ML3GLM18qnDecisionFunctionEvRKN4raft8handle_tERK9qn_paramsP1Tb1I1I1IP1TP1T) D, [I](#_CPPv4I00EN2ML3GLM18qnDecisionFunctionEvRKN4raft8handle_tERK9qn_paramsP1Tb1I1I1IP1TP1T) C, [T](#_CPPv4I00EN2ML3GLM18qnDecisionFunctionEvRKN4raft8handle_tERK9qn_paramsP1Tb1I1I1IP1TP1T) \*coefs, [T](#_CPPv4I00EN2ML3GLM18qnDecisionFunctionEvRKN4raft8handle_tERK9qn_paramsP1Tb1I1I1IP1TP1T) \*scores)

Obtain the confidence scores of samples. 

* **Parameters:**
  * **cuml_handle** – reference to raft::handle_t object 
  * **params** – model parameters 
  * **X** – device pointer to a contiguous feature matrix of dimension [N, D] 
  * **X_col_major** – true if X is stored column-major 
  * **N** – number of examples 
  * **D** – number of features 
  * **C** – number of outputs (number of classes or `1` for regression) 
  * **coefs** – device pointer to model coefficients. Length D if fit_intercept == false else D+1 
  * **scores** – device pointer to confidence scores of length N (for binary logistic: [0,1], for multinomial: [0,…,C-1]) 

### template<typename T, typename I = int>void qnDecisionFunctionSparse(const raft::handle_t &cuml_handle, const qn_params &params, [T](#_CPPv4I00EN2ML3GLM24qnDecisionFunctionSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) \*X_values, [I](#_CPPv4I00EN2ML3GLM24qnDecisionFunctionSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) \*X_cols, [I](#_CPPv4I00EN2ML3GLM24qnDecisionFunctionSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) \*X_row_ids, [I](#_CPPv4I00EN2ML3GLM24qnDecisionFunctionSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) X_nnz, [I](#_CPPv4I00EN2ML3GLM24qnDecisionFunctionSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) N, [I](#_CPPv4I00EN2ML3GLM24qnDecisionFunctionSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) D, [I](#_CPPv4I00EN2ML3GLM24qnDecisionFunctionSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) C, [T](#_CPPv4I00EN2ML3GLM24qnDecisionFunctionSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) \*coefs, [T](#_CPPv4I00EN2ML3GLM24qnDecisionFunctionSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) \*scores)

Obtain the confidence scores of samples. 

* **Parameters:**
  * **cuml_handle** – reference to raft::handle_t object 
  * **params** – model parameters 
  * **X_values** – feature matrix values (CSR format), length = X_nnz 
  * **X_cols** – feature matrix columns (CSR format), length = X_nnz, range = [0, … D-1] 
  * **X_row_ids** – feature matrix compressed row ids (CSR format), length = N + 1, range = [0, … X_nnz] 
  * **X_nnz** – number of non-zero entries in the feature matrix (CSR format) 
  * **N** – number of examples 
  * **D** – number of features 
  * **C** – number of outputs (number of classes or `1` for regression) 
  * **coefs** – device pointer to model coefficients. Length D if fit_intercept == false else D+1 
  * **scores** – device pointer to confidence scores of length N (for binary logistic: [0,1], for multinomial: [0,…,C-1]) 

### template<typename T, typename I = int>void qnPredict(const raft::handle_t &cuml_handle, const qn_params &params, [T](#_CPPv4I00EN2ML3GLM9qnPredictEvRKN4raft8handle_tERK9qn_paramsP1Tb1I1I1IP1TP1T) \*X, bool X_col_major, [I](#_CPPv4I00EN2ML3GLM9qnPredictEvRKN4raft8handle_tERK9qn_paramsP1Tb1I1I1IP1TP1T) N, [I](#_CPPv4I00EN2ML3GLM9qnPredictEvRKN4raft8handle_tERK9qn_paramsP1Tb1I1I1IP1TP1T) D, [I](#_CPPv4I00EN2ML3GLM9qnPredictEvRKN4raft8handle_tERK9qn_paramsP1Tb1I1I1IP1TP1T) C, [T](#_CPPv4I00EN2ML3GLM9qnPredictEvRKN4raft8handle_tERK9qn_paramsP1Tb1I1I1IP1TP1T) \*coefs, [T](#_CPPv4I00EN2ML3GLM9qnPredictEvRKN4raft8handle_tERK9qn_paramsP1Tb1I1I1IP1TP1T) \*preds)

Predict a [GLM](#namespaceML_1_1GLM) using quasi newton methods. 

* **Parameters:**
  * **cuml_handle** – reference to raft::handle_t object 
  * **params** – model parameters 
  * **X** – device pointer to a contiguous feature matrix of dimension [N, D] 
  * **X_col_major** – true if X is stored column-major 
  * **N** – number of examples 
  * **D** – number of features 
  * **C** – number of outputs (number of classes or `1` for regression) 
  * **coefs** – device pointer to model coefficients. Length D if fit_intercept == false else D+1 
  * **preds** – device pointer to predictions of length N (for binary logistic: [0,1], for multinomial: [0,…,C-1]) 

### template<typename T, typename I = int>void qnPredictSparse(const raft::handle_t &cuml_handle, const qn_params &params, [T](#_CPPv4I00EN2ML3GLM15qnPredictSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) \*X_values, [I](#_CPPv4I00EN2ML3GLM15qnPredictSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) \*X_cols, [I](#_CPPv4I00EN2ML3GLM15qnPredictSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) \*X_row_ids, [I](#_CPPv4I00EN2ML3GLM15qnPredictSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) X_nnz, [I](#_CPPv4I00EN2ML3GLM15qnPredictSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) N, [I](#_CPPv4I00EN2ML3GLM15qnPredictSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) D, [I](#_CPPv4I00EN2ML3GLM15qnPredictSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) C, [T](#_CPPv4I00EN2ML3GLM15qnPredictSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) \*coefs, [T](#_CPPv4I00EN2ML3GLM15qnPredictSparseEvRKN4raft8handle_tERK9qn_paramsP1TP1IP1I1I1I1I1IP1TP1T) \*preds)

Predict a [GLM](#namespaceML_1_1GLM) using quasi newton methods. 

* **Parameters:**
  * **cuml_handle** – reference to raft::handle_t object 
  * **params** – model parameters 
  * **X_values** – feature matrix values (CSR format), length = X_nnz 
  * **X_cols** – feature matrix columns (CSR format), length = X_nnz, range = [0, … D-1] 
  * **X_row_ids** – feature matrix compressed row ids (CSR format), length = N + 1, range = [0, … X_nnz] 
  * **X_nnz** – number of non-zero entries in the feature matrix (CSR format) 
  * **N** – number of examples 
  * **D** – number of features 
  * **C** – number of outputs (number of classes or `1` for regression) 
  * **coefs** – device pointer to model coefficients. Length D if fit_intercept == false else D+1 
  * **preds** – device pointer to predictions of length N (for binary logistic: [0,1], for multinomial: [0,…,C-1]) 

### namespace opg

### Functions

### void preProcessData(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> &labels, float \*mu_input, float \*mu_labels, bool fit_intercept, cudaStream_t \*streams, int n_streams, bool verbose)

### void preProcessData(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double>\*> &labels, double \*mu_input, double \*mu_labels, bool fit_intercept, cudaStream_t \*streams, int n_streams, bool verbose)

### void postProcessData(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> &labels, float \*coef, float \*intercept, float \*mu_input, float \*mu_labels, bool fit_intercept, cudaStream_t \*streams, int n_streams, bool verbose)

### void postProcessData(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double>\*> &labels, double \*coef, double \*intercept, double \*mu_input, double \*mu_labels, bool fit_intercept, cudaStream_t \*streams, int n_streams, bool verbose)

### template<typename T>std::vector<[T](#_CPPv4I0EN2ML3GLM3opg17getUniquelabelsMGENSt6vectorI1TEERKN4raft8handle_tERN8MLCommon6Matrix14PartDescriptorERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEE)> getUniquelabelsMG(const raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<[T](#_CPPv4I0EN2ML3GLM3opg17getUniquelabelsMGENSt6vectorI1TEERKN4raft8handle_tERN8MLCommon6Matrix14PartDescriptorERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEE)>\*> &labels)

Calculate unique class labels across multiple GPUs in a multi-node environment. 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **input_desc** – **[in]** PartDescriptor object for the input 
  * **labels** – **[in]** labels data 
* **Returns:**
  host vector that stores the distinct labels 

### template<typename T>void qnFit(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<[T](#_CPPv4I0EN2ML3GLM3opg5qnFitEvRN4raft8handle_tERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEERN8MLCommon6Matrix14PartDescriptorERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1TRK9qn_paramsbbiP1TPi)>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<[T](#_CPPv4I0EN2ML3GLM3opg5qnFitEvRN4raft8handle_tERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEERN8MLCommon6Matrix14PartDescriptorERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1TRK9qn_paramsbbiP1TPi)>\*> &labels, [T](#_CPPv4I0EN2ML3GLM3opg5qnFitEvRN4raft8handle_tERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEERN8MLCommon6Matrix14PartDescriptorERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1TRK9qn_paramsbbiP1TPi) \*coef, const qn_params &pams, bool X_col_major, bool standardization, int n_classes, [T](#_CPPv4I0EN2ML3GLM3opg5qnFitEvRN4raft8handle_tERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEERN8MLCommon6Matrix14PartDescriptorERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1TRK9qn_paramsbbiP1TPi) \*f, int \*num_iters)

performs MNMG fit operation for the logistic regression using quasi newton methods 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **input_data** – **[in]** vector holding all partitions for that rank 
  * **input_desc** – **[in]** PartDescriptor object for the input 
  * **labels** – **[in]** labels data 
  * **coef** – **[out]** learned coefficients 
  * **pams** – **[in]** model parameters 
  * **X_col_major** – **[in]** true if X is stored column-major 
  * **standardization** – **[in]** whether to standardize the dataset before training 
  * **n_classes** – **[in]** number of outputs (number of classes or `1` for regression) 
  * **f** – **[out]** host pointer holding the final objective value 
  * **num_iters** – **[out]** host pointer holding the actual number of iterations taken 

### template<typename T, typename I>void qnFitSparse(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<[T](#_CPPv4I00EN2ML3GLM3opg11qnFitSparseEvRN4raft8handle_tERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1IP1I1IRN8MLCommon6Matrix14PartDescriptorERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1TRK9qn_paramsbiP1TPi)>\*> &input_values, [I](#_CPPv4I00EN2ML3GLM3opg11qnFitSparseEvRN4raft8handle_tERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1IP1I1IRN8MLCommon6Matrix14PartDescriptorERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1TRK9qn_paramsbiP1TPi) \*input_cols, [I](#_CPPv4I00EN2ML3GLM3opg11qnFitSparseEvRN4raft8handle_tERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1IP1I1IRN8MLCommon6Matrix14PartDescriptorERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1TRK9qn_paramsbiP1TPi) \*input_row_ids, [I](#_CPPv4I00EN2ML3GLM3opg11qnFitSparseEvRN4raft8handle_tERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1IP1I1IRN8MLCommon6Matrix14PartDescriptorERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1TRK9qn_paramsbiP1TPi) X_nnz, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<[T](#_CPPv4I00EN2ML3GLM3opg11qnFitSparseEvRN4raft8handle_tERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1IP1I1IRN8MLCommon6Matrix14PartDescriptorERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1TRK9qn_paramsbiP1TPi)>\*> &labels, [T](#_CPPv4I00EN2ML3GLM3opg11qnFitSparseEvRN4raft8handle_tERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1IP1I1IRN8MLCommon6Matrix14PartDescriptorERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1TRK9qn_paramsbiP1TPi) \*coef, const qn_params &pams, bool standardization, int n_classes, [T](#_CPPv4I00EN2ML3GLM3opg11qnFitSparseEvRN4raft8handle_tERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1IP1I1IRN8MLCommon6Matrix14PartDescriptorERNSt6vectorIPN8MLCommon6Matrix4DataI1TEEEEP1TRK9qn_paramsbiP1TPi) \*f, int \*num_iters)

support sparse vectors (Compressed [Sparse](#namespaceML_1_1Sparse) Row format) for MNMG logistic regression fit using quasi newton methods 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **input_values** – **[in]** vector holding non-zero values of all partitions for that rank 
  * **input_cols** – **[in]** vector holding column indices of non-zero values of all partitions for that rank 
  * **input_row_ids** – **[in]** vector holding row pointers of non-zero values of all partitions for that rank 
  * **X_nnz** – **[in]** the number of non-zero values of that rank 
  * **standardization** – **[in]** whether to standardize the dataset before training 
  * **input_desc** – **[in]** PartDescriptor object for the input 
  * **labels** – **[in]** labels data 
  * **coef** – **[out]** learned coefficients 
  * **pams** – **[in]** model parameters 
  * **n_classes** – **[in]** number of outputs (number of classes or `1` for regression) 
  * **f** – **[out]** host pointer holding the final objective value 
  * **num_iters** – **[out]** host pointer holding the actual number of iterations taken 

### namespace graph_build_params

### struct nn_descent_params_umap

 *#include <umapparams.h>*

Arguments for using nn descent as the knn build algorithm. graph_degree must be larger than or equal to n_neighbors. Increasing graph_degree and max_iterations may result in better accuracy. Smaller termination threshold means stricter convergence criteria for nn descent and may take longer to converge. 

### struct graph_build_params

 *#include <umapparams.h>*

Parameters for knn graph building in [UMAP](#namespaceML_1_1UMAP). [Hint1]: the ratio of overlap_factor / n_clusters determines device memory usage. Approximately (overlap_factor / n_clusters) \* num_rows_in_entire_data number of rows will be put on device memory at once. E.g. between (overlap_factor / n_clusters) = 2/10 and 2/20, the latter will use less device memory. [Hint2]: larger overlap_factor results in better accuracy of the final all-neighbors knn graph. E.g. While using similar amount of device memory, (overlap_factor / n_clusters) = 4/20 will have better accuracy than 2/10 at the cost of performance. [Hint3]: for overlap_factor, start with 2, and gradually increase (2->3->4 …) for better accuracy [Hint4]: for n_clusters, start with 4, and gradually increase(4->8->16 …) for less GPU memory usage. This is independent from overlap_factor as long as overlap_factor < n_clusters 

### Public Members

### size_t overlap_factor = 2

Number of clusters each data point is assigned to. Only valid when n_clusters > 1. 

### size_t n_clusters = 1

Number of clusters to split the data into when building the knn graph. Increasing this will use less device memory at the cost of accuracy. When using n_clusters > 1, is is required that the data is put on host (refer to data_on_host argument for fit_transform). The default value (n_clusters=1) will place the entire data on device memory. 

### namespace HDBSCAN

### namespace Common

### Enums

### enum CLUSTER_SELECTION_METHOD

*Values:*

### enumerator EOM

### enumerator LEAF

### enum GRAPH_BUILD_ALGO

*Values:*

### enumerator BRUTE_FORCE_KNN

### enumerator NN_DESCENT

### Functions

### void generate_prediction_data(const raft::handle_t &handle, [CondensedHierarchy](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE)<int64_t, float> &condensed_tree, int64_t \*labels, int64_t \*inverse_label_map, int n_selected_clusters, [PredictionData](#_CPPv4I00EN2ML7HDBSCAN6Common14PredictionDataE)<int64_t, float> &prediction_data)

### template<typename value_idx, typename value_t>class CondensedHierarchy

 *#include <hdbscan.hpp>*

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.

* **Template Parameters:**
  * **value_idx** – 
  * **value_t** – 

### Public Functions

### CondensedHierarchy(const raft::handle_t &handle_, size_t n_leaves_)

Constructs an empty condensed hierarchy object which requires [condense()](#classML_1_1HDBSCAN_1_1Common_1_1CondensedHierarchy_1acddf2e64234478f4765b8303e5029d7d) to be called in order to populate the state. 

* **Parameters:**
  * **handle_** – 
  * **n_leaves_** – 

### CondensedHierarchy(const raft::handle_t &handle_, size_t n_leaves_, int n_edges_, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE) \*parents_, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE) \*children_, [value_t](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE) \*lambdas_, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE) \*sizes_)

Constructs a condensed hierarchy object with existing arrays which already contain a condensed hierarchy. 

* **Parameters:**
  * **handle_** – 
  * **n_leaves_** – 
  * **n_edges_** – 
  * **parents_** – 
  * **children_** – 
  * **lambdas_** – 
  * **sizes_** – 

### CondensedHierarchy(const raft::handle_t &handle_, size_t n_leaves_, int n_edges_, int n_clusters_, [rmm](https://docs.nvidia.com/rmm/latest/cpp/rmm_namespace/#_CPPv43rmm)::device_uvector<[value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE)> &&parents_, [rmm](https://docs.nvidia.com/rmm/latest/cpp/rmm_namespace/#_CPPv43rmm)::device_uvector<[value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE)> &&children_, [rmm](https://docs.nvidia.com/rmm/latest/cpp/rmm_namespace/#_CPPv43rmm)::device_uvector<[value_t](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE)> &&lambdas_, [rmm](https://docs.nvidia.com/rmm/latest/cpp/rmm_namespace/#_CPPv43rmm)::device_uvector<[value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE)> &&sizes_)

Constructs a condensed hierarchy object by moving rmm::device_uvector. Used to construct cluster trees 

* **Parameters:**
  * **handle_** – 
  * **n_leaves_** – 
  * **n_edges_** – 
  * **n_clusters_** – 
  * **parents_** – 
  * **children_** – 
  * **lambdas_** – 
  * **sizes_** – 

### void condense([value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE) \*full_parents, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE) \*full_children, [value_t](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE) \*full_lambdas, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE) \*full_sizes, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE) size = -1)

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. 

### class RobustSingleLinkageParams

 *#include <hdbscan.hpp>*

Subclassed by [ML::HDBSCAN::Common::HDBSCANParams](#classML_1_1HDBSCAN_1_1Common_1_1HDBSCANParams)

### class HDBSCANParams : public [ML](#_CPPv42ML)::[HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[RobustSingleLinkageParams](#_CPPv4N2ML7HDBSCAN6Common25RobustSingleLinkageParamsE)

 *#include <hdbscan.hpp>*

### template<typename value_idx, typename value_t>class robust_single_linkage_output

 *#include <hdbscan.hpp>*

Container object for output information common between robust single linkage variants. 

* **Template Parameters:**
  * **value_idx** – 
  * **value_t** – 

Subclassed by [ML::HDBSCAN::Common::hdbscan_output< value_idx, value_t >](#classML_1_1HDBSCAN_1_1Common_1_1hdbscan__output)

### Public Functions

### inline robust_single_linkage_output(const raft::handle_t &handle_, int n_leaves_, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common28robust_single_linkage_outputE) \*labels_, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common28robust_single_linkage_outputE) \*children_, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common28robust_single_linkage_outputE) \*sizes_, [value_t](#_CPPv4I00EN2ML7HDBSCAN6Common28robust_single_linkage_outputE) \*deltas_, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common28robust_single_linkage_outputE) \*mst_src_, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common28robust_single_linkage_outputE) \*mst_dst_, [value_t](#_CPPv4I00EN2ML7HDBSCAN6Common28robust_single_linkage_outputE) \*mst_weights_)

Construct output object with empty device arrays of known size. 

* **Parameters:**
  * **handle_** – raft handle for ordering cuda operations 
  * **n_leaves_** – number of data points 
  * **labels_** – labels array on device (size n_leaves) 
  * **children_** – dendrogram src/dst array (size n_leaves - 1, 2) 
  * **sizes_** – dendrogram cluster sizes array (size n_leaves - 1) 
  * **deltas_** – dendrogram distances array (size n_leaves - 1) 
  * **mst_src_** – min spanning tree source array (size n_leaves - 1) 
  * **mst_dst_** – min spanning tree destination array (size n_leaves - 1) 
  * **mst_weights_** – min spanninng tree distances array (size n_leaves - 1) 

### inline void set_n_clusters(int n_clusters_)

The number of clusters is set by the algorithm once it is known. 

* **Parameters:**
  **n_clusters_** – number of resulting clusters 

### template<typename value_idx, typename value_t>class hdbscan_output : public [ML](#_CPPv42ML)::[HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[robust_single_linkage_output](#_CPPv4I00EN2ML7HDBSCAN6Common28robust_single_linkage_outputE)<[value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common14hdbscan_outputE), [value_t](#_CPPv4I00EN2ML7HDBSCAN6Common14hdbscan_outputE)>

 *#include <hdbscan.hpp>*

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. 

* **Template Parameters:**
  * **value_idx** – 
  * **value_t** – 

### Public Functions

### inline void set_n_clusters(int n_clusters_)

Once n_clusters is known, the stabilities array can be initialized. 

* **Parameters:**
  **n_clusters_** – 

### template<typename value_idx, typename value_t>class PredictionData

 *#include <hdbscan.hpp>*

Container object for computing and storing intermediate information needed later for computing membership vectors and approximate predict. Users are only expected to create an instance of this object, the hdbscan method will do the rest. 

* **Template Parameters:**
  * **value_idx** – 
  * **value_t** – 

### Public Functions

### void allocate(const raft::handle_t &handle, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common14PredictionDataE) n_exemplars_, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common14PredictionDataE) n_selected_clusters_, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common14PredictionDataE) n_edges_)

Resizes the buffers in the [PredictionData](#classML_1_1HDBSCAN_1_1Common_1_1PredictionData) object.

* **Parameters:**
  * **handle** – **[in]** raft handle for resource reuse 
  * **n_exemplars_** – **[in]** number of exemplar points 
  * **n_selected_clusters_** – **[in]** number of selected clusters in the final clustering 
  * **n_edges_** – **[in]** number of edges in the condensed hierarchy 

### inline void set_n_clusters(const raft::handle_t &handle, [value_idx](#_CPPv4I00EN2ML7HDBSCAN6Common14PredictionDataE) n_clusters_)

Resize buffers for cluster deaths to n_clusters 

* **Parameters:**
  * **handle** – raft handle for ordering cuda operations 
  * **n_clusters_** – number of clusters 

### namespace graph_build_params

### struct nn_descent_params_hdbscan

 *#include <hdbscan.hpp>*

Arguments for using nn descent as the knn build algorithm. graph_degree must be larger than or equal to min_samples+1. Increasing graph_degree and max_iterations may result in better accuracy. Smaller termination threshold means stricter convergence criteria for nn descent and may take longer to converge. 

### struct graph_build_params

 *#include <hdbscan.hpp>*

Parameters for knn graph building in [HDBSCAN](#namespaceML_1_1HDBSCAN). Enables building the mutual reachability graph on datasets larger than device memory by:
1. Partitioning the dataset into overlapping clusters,
2. Computing local [KNN](#namespaceML_1_1KNN) graphs within each cluster, and
3. Merging the local graphs into a single global graph.

Guidelines for choosing parameters:
1. the ratio of overlap_factor / n_clusters determines device memory usage. Approximately (overlap_factor / n_clusters) \* num_rows_in_entire_data number of rows will be put on device memory at once. E.g. between (overlap_factor / n_clusters) = 2/10 and 2/20, the latter will use less device memory.
2. larger overlap_factor results in better accuracy of the final all-neighbors knn graph. E.g. While using similar amount of device memory, (overlap_factor / n_clusters) = 4/20 will have better accuracy than 2/10 at the cost of performance.
3. for overlap_factor, start with 2, and gradually increase (2->3->4 …) for better accuracy
4. for n_clusters, start with 4, and gradually increase(4->8->16 …) for less GPU memory usage. This is independent from overlap_factor as long as overlap_factor < n_clusters 

### Public Members

### size_t overlap_factor = 2

Number of clusters each data point is assigned to. Only valid when n_clusters > 1. 

### size_t n_clusters = 1

Number of clusters to split the data into when building the knn graph. Increasing this will use less device memory at the cost of accuracy. When using n_clusters > 1, is is required that the data is put on host (refer to data_on_host argument for fit_transform). The default value (n_clusters=1) will place the entire data on device memory. 

### namespace HELPER

### Functions

### void compute_core_dists(const raft::handle_t &handle, const float \*X, float \*core_dists, size_t m, size_t n, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric, int min_samples)

Compute the core distances for each point in the training matrix. 

* **Parameters:**
  * **handle** – **[in]** raft handle for resource reuse 
  * **X** – **[in]** array (size m, n) on device in row-major format 
  * **core_dists** – **[out]** array (size m, 1) of core distances 
  * **m** – number of rows in X 
  * **n** – number of columns in X 
  * **metric** – distance metric to use 
  * **min_samples** – minimum number of samples to use for computing core distances 

### void compute_inverse_label_map(const raft::handle_t &handle, [HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[CondensedHierarchy](#_CPPv4I00EN2ML7HDBSCAN6Common18CondensedHierarchyE)<int64_t, float> &condensed_tree, size_t n_leaves, [HDBSCAN](#_CPPv4N2ML7HDBSCANE)::[Common](#_CPPv4N2ML7HDBSCAN6CommonE)::[CLUSTER_SELECTION_METHOD](#_CPPv4N2ML7HDBSCAN6Common24CLUSTER_SELECTION_METHODE) cluster_selection_method, [rmm](https://docs.nvidia.com/rmm/latest/cpp/rmm_namespace/#_CPPv43rmm)::device_uvector<int64_t> &inverse_label_map, bool allow_single_cluster, int64_t max_cluster_size, float cluster_selection_epsilon)

Compute the map from final, normalize labels to the labels in the CondensedHierarchy. 

* **Parameters:**
  * **handle** – **[in]** raft handle for resource reuse 
  * **condensed_tree** – **[in]** the Condensed Hierarchy object 
  * **n_leaves** – **[in]** number of leaves in the input data 
  * **cluster_selection_method** – **[in]** cluster selection method 
  * **inverse_label_map** – **[out]** rmm::device_uvector of size 0. It will be resized during the computation 
  * **allow_single_cluster** – **[in]** allow single cluster 
  * **max_cluster_size** – **[in]** max cluster size 
  * **cluster_selection_epsilon** – **[in]** cluster selection epsilon 

### namespace Internals

### class Callback

 *#include <callback.hpp>*

Subclassed by [ML::Internals::GraphBasedDimRedCallback](#classML_1_1Internals_1_1GraphBasedDimRedCallback)

### class GraphBasedDimRedCallback : public [ML](#_CPPv42ML)::[Internals](#_CPPv4N2ML9InternalsE)::[Callback](#_CPPv4N2ML9Internals8CallbackE)

 *#include <callback.hpp>*

### namespace KDE

### Enums

### enum class DensityKernelType : int

*Values:*

### enumerator Gaussian

### enumerator Tophat

### enumerator Epanechnikov

### enumerator Exponential

### enumerator Linear

### enumerator Cosine

### Functions

### template<typename T>void score_samples(raft::resources const &handle, const [T](#_CPPv4I0EN2ML3KDE13score_samplesEvRKN4raft9resourcesEPK1TPK1TPK1TP1TNSt7int64_tENSt7int64_tENSt7int64_tE1T1T17DensityKernelTypeN2ML8distance12DistanceTypeE1T) \*query, const [T](#_CPPv4I0EN2ML3KDE13score_samplesEvRKN4raft9resourcesEPK1TPK1TPK1TP1TNSt7int64_tENSt7int64_tENSt7int64_tE1T1T17DensityKernelTypeN2ML8distance12DistanceTypeE1T) \*train, const [T](#_CPPv4I0EN2ML3KDE13score_samplesEvRKN4raft9resourcesEPK1TPK1TPK1TP1TNSt7int64_tENSt7int64_tENSt7int64_tE1T1T17DensityKernelTypeN2ML8distance12DistanceTypeE1T) \*weights, [T](#_CPPv4I0EN2ML3KDE13score_samplesEvRKN4raft9resourcesEPK1TPK1TPK1TP1TNSt7int64_tENSt7int64_tENSt7int64_tE1T1T17DensityKernelTypeN2ML8distance12DistanceTypeE1T) \*output, std::int64_t n_query, std::int64_t n_train, std::int64_t n_features, [T](#_CPPv4I0EN2ML3KDE13score_samplesEvRKN4raft9resourcesEPK1TPK1TPK1TP1TNSt7int64_tENSt7int64_tENSt7int64_tE1T1T17DensityKernelTypeN2ML8distance12DistanceTypeE1T) bandwidth, [T](#_CPPv4I0EN2ML3KDE13score_samplesEvRKN4raft9resourcesEPK1TPK1TPK1TP1TNSt7int64_tENSt7int64_tENSt7int64_tE1T1T17DensityKernelTypeN2ML8distance12DistanceTypeE1T) sum_weights, [DensityKernelType](#_CPPv4N2ML3KDE17DensityKernelTypeE) kernel, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric, [T](#_CPPv4I0EN2ML3KDE13score_samplesEvRKN4raft9resourcesEPK1TPK1TPK1TP1TNSt7int64_tENSt7int64_tENSt7int64_tE1T1T17DensityKernelTypeN2ML8distance12DistanceTypeE1T) metric_arg)

Compute normalized log-density scores for query samples. 

The query and training arrays must be dense row-major (C-contiguous) device arrays with shapes `(n_query, n_features)` and `(n_train, n_features)`, respectively.

* **Template Parameters:**
  **T** – floating point type, either float or double 
* **Parameters:**
  * **handle** – **[in]** raft resources used to launch work 
  * **query** – **[in]** device pointer to query samples in row-major order 
  * **train** – **[in]** device pointer to training samples in row-major order 
  * **weights** – **[in]** optional device pointer to sample weights of length `n_train`, or nullptr for uniform weights 
  * **output** – **[out]** device pointer to log-density scores of length `n_query`
  * **n_query** – **[in]** number of query samples 
  * **n_train** – **[in]** number of training samples 
  * **n_features** – **[in]** number of features per sample 
  * **bandwidth** – **[in]** positive [KDE](#namespaceML_1_1KDE) bandwidth 
  * **sum_weights** – **[in]** sum of `weights`, or `n_train` when weights is null 
  * **kernel** – **[in]** density kernel to evaluate 
  * **metric** – **[in]** distance metric used between query and training samples 
  * **metric_arg** – **[in]** metric-specific argument, such as p for Minkowski 

### namespace kmeans

### Functions

### void fit(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const float \*X, int n_samples, int n_features, const float \*sample_weight, float \*centroids, float &inertia, int &n_iter)

Compute k-means clustering for each sample in the input. 

* **Parameters:**
  * **handle** – **[in]** The handle to the cuML library context that manages the CUDA resources. 
  * **params** – **[in]** Parameters for KMeans model. 
  * **X** – **[in]** Training instances to cluster, in row-major format. May or may not be device accessible. 
  * **n_samples** – **[in]** Number of samples in the input X. 
  * **n_features** – **[in]** Number of features or the dimensions of each sample. 
  * **sample_weight** – **[in]** The weights for each observation in X. If non-null, sample_weight must have the same memory residency as X. 
  * **centroids** – **[inout]** [in] When init is InitMethod::Array, use centroids as the initial cluster centers [out] Otherwise, generated centroids from the kmeans algorithm is stored at the address pointed by ‘centroids’. `centroids` must always be device accessible. 
  * **inertia** – **[out]** Sum of squared distances of samples to their closest cluster center. 
  * **n_iter** – **[out]** Number of iterations run. 

### void fit(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const double \*X, int n_samples, int n_features, const double \*sample_weight, double \*centroids, double &inertia, int &n_iter)

### void fit(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const float \*X, int64_t n_samples, int64_t n_features, const float \*sample_weight, float \*centroids, float &inertia, int64_t &n_iter)

### void fit(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const double \*X, int64_t n_samples, int64_t n_features, const double \*sample_weight, double \*centroids, double &inertia, int64_t &n_iter)

### void fit(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const float \*const \*X_parts, const int64_t \*n_samples_parts, int64_t n_parts, int64_t n_features, const float \*const \*sample_weight_parts, float \*centroids, float &inertia, int64_t &n_iter)

Multi-GPU / out-of-core k-means fit over multiple local data partitions. 

Each rank (e.g. each Dask worker) supplies its local training data as an array of `n_parts` partitions. All partitions on a given rank must share the same residency. The distributed reduction across ranks is performed via the NCCL communicator that must be initialized on `handle`.

* **Parameters:**
  * **handle** – **[in]** cuML handle with NCCL comms initialized. 
  * **params** – **[in]** Parameters for the KMeans model. For host-resident partitions the host-to-device batch size is read from `params.device_buffer_samples`. 
  * **X_parts** – **[in]** Array of `n_parts` pointers to the local row-major partitions (all host- or all device-resident). Partition `i` has shape [`n_samples_parts[i]`, `n_features`]. 
  * **n_samples_parts** – **[in]** Array of `n_parts` per-partition row counts. 
  * **n_parts** – **[in]** Number of local partitions on this rank. 
  * **n_features** – **[in]** Number of features (shared by all partitions). 
  * **sample_weight_parts** – **[in]** Optional array of `n_parts` pointers to the per-partition weight vectors (matching the residency of `X_parts`), or `nullptr` for uniform weights. 
  * **centroids** – **[inout]** Device matrix [n_clusters x n_features]. 
  * **inertia** – **[out]** Sum of squared distances to closest center. 
  * **n_iter** – **[out]** Number of iterations run. 

### void fit(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const double \*const \*X_parts, const int64_t \*n_samples_parts, int64_t n_parts, int64_t n_features, const double \*const \*sample_weight_parts, double \*centroids, double &inertia, int64_t &n_iter)

### void predict(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const float \*centroids, const float \*X, int n_samples, int n_features, const float \*sample_weight, bool normalize_weights, int \*labels, float &inertia)

Predict the closest cluster each sample in X belongs to. 

* **Parameters:**
  * **handle** – **[in]** The handle to the cuML library context that manages the CUDA resources. 
  * **params** – **[in]** Parameters for KMeans model. 
  * **centroids** – **[in]** Cluster centroids. It must be noted that the data must be in row-major format and stored in device accessible location. 
  * **X** – **[in]** New data to predict. 
  * **n_samples** – **[in]** Number of samples in the input X. 
  * **n_features** – **[in]** Number of features or the dimensions of each sample in ‘X’ (value should be same as the dimension for each cluster centers in ‘centroids’). 
  * **sample_weight** – **[in]** The weights for each observation in X. 
  * **normalize_weights** – **[in]** True if the weights should be normalized 
  * **labels** – **[out]** Index of the cluster each sample in X belongs to. 
  * **inertia** – **[out]** Sum of squared distances of samples to their closest cluster center. 

### void predict(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const double \*centroids, const double \*X, int n_samples, int n_features, const double \*sample_weight, bool normalize_weights, int \*labels, double &inertia)

### void predict(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const float \*centroids, const float \*X, int64_t n_samples, int64_t n_features, const float \*sample_weight, bool normalize_weights, int64_t \*labels, float &inertia)

### void predict(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const double \*centroids, const double \*X, int64_t n_samples, int64_t n_features, const double \*sample_weight, bool normalize_weights, int64_t \*labels, double &inertia)

### void transform(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const float \*centroids, const float \*X, int n_samples, int n_features, float \*X_new)

Transform X to a cluster-distance space. 

* **Parameters:**
  * **handle** – **[in]** The handle to the cuML library context that manages the CUDA resources. 
  * **params** – **[in]** Parameters for KMeans model. 
  * **centroids** – **[in]** Cluster centroids. It must be noted that the data must be in row-major format and stored in device accessible location. 
  * **X** – **[in]** Training instances to cluster. It must be noted that the data must be in row-major format and stored in device accessible location. 
  * **n_samples** – **[in]** Number of samples in the input X. 
  * **n_features** – **[in]** Number of features or the dimensions of each sample in ‘X’ (it should be same as the dimension for each cluster centers in ‘centroids’). 
  * **X_new** – **[out]** X transformed in the new space.. 

### void transform(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const double \*centroids, const double \*X, int n_samples, int n_features, double \*X_new)

### void transform(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const float \*centroids, const float \*X, int64_t n_samples, int64_t n_features, float \*X_new)

### void transform(const raft::handle_t &handle, const [KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) &params, const double \*centroids, const double \*X, int64_t n_samples, int64_t n_features, double \*X_new)

### inline cuvs::cluster::kmeans::params to_cuvs([KMeansParams](#_CPPv4N2ML6kmeans12KMeansParamsE) const &config)

### struct KMeansParams

 *#include <kmeans_params.hpp>*

### namespace KNN

### namespace opg

### Functions

### void knn(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<int64_t>\*> \*out_I, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[floatData_t](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix11floatData_tE)\*> \*out_D, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[floatData_t](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix11floatData_tE)\*> &idx_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &idx_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[floatData_t](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix11floatData_tE)\*> &query_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &query_desc, bool rowMajorIndex, bool rowMajorQuery, int k, size_t batch_size, bool verbose)

Performs a multi-node multi-GPU [KNN](#namespaceML_1_1KNN). 

* **Parameters:**
  * **handle** – **[in]** the raft::handle_t to use for managing resources 
  * **out_I** – **[out]** vector of output index partitions. size should match the number of local input partitions. 
  * **out_D** – **[out]** vector of output distance partitions. size should match the number of local input partitions. 
  * **idx_data** – **[in]** vector of local indices to query 
  * **idx_desc** – **[in]** describes how the index partitions are distributed across the ranks. 
  * **query_data** – **[in]** vector of local query partitions 
  * **query_desc** – **[in]** describes how the query partitions are distributed across the cluster. 
  * **rowMajorIndex** – **[in]** boolean indicating whether the index is row major. 
  * **rowMajorQuery** – **[in]** boolean indicating whether the query is row major. 
  * **k** – **[in]** the number of neighbors to query 
  * **batch_size** – **[in]** the max number of rows to broadcast at a time 
  * **verbose** – **[in]** print extra logging info 

### void knn_classify(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<int>\*> \*out, std::vector<std::vector<float\*>> \*probas, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[floatData_t](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix11floatData_tE)\*> &idx_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &idx_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[floatData_t](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix11floatData_tE)\*> &query_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &query_desc, std::vector<std::vector<int\*>> &y, std::vector<int\*> &uniq_labels, std::vector<int> &n_unique, bool rowMajorIndex = false, bool rowMajorQuery = false, bool probas_only = false, int k = 10, size_t batch_size = 1 << 15, bool verbose = false)

Performs a multi-node multi-GPU [KNN](#namespaceML_1_1KNN) classify. 

* **Parameters:**
  * **handle** – **[in]** the raft::handle_t to use for managing resources 
  * **out** – **[out]** vector of output labels partitions. size should match the number of local input partitions. 
  * **probas** – **[in]** (optional) pointer to a vector containing arrays of probabilities 
  * **idx_data** – **[in]** vector of local indices to query 
  * **idx_desc** – **[in]** describes how the index partitions are distributed across the ranks. 
  * **query_data** – **[in]** vector of local query partitions 
  * **query_desc** – **[in]** describes how the query partitions are distributed across the cluster. 
  * **y** – **[in]** vector of vector of label arrays. for multilabel classification, each element in the vector is a different “output” array of labels corresponding to the i’th output. size should match the number of local input partitions. 
  * **uniq_labels** – **[in]** vector of the sorted unique labels for each array in y 
  * **n_unique** – **[in]** vector of sizes for each array in uniq_labels 
  * **rowMajorIndex** – **[in]** boolean indicating whether the index is row major. 
  * **rowMajorQuery** – **[in]** boolean indicating whether the query is row major. 
  * **probas_only** – **[in]** return probas instead of performing complete knn_classify 
  * **k** – **[in]** the number of neighbors to query 
  * **batch_size** – **[in]** the max number of rows to broadcast at a time 
  * **verbose** – **[in]** print extra logging info 

### void knn_regress(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> \*out, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[floatData_t](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix11floatData_tE)\*> &idx_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &idx_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[floatData_t](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix11floatData_tE)\*> &query_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &query_desc, std::vector<std::vector<float\*>> &y, bool rowMajorIndex, bool rowMajorQuery, int k, int n_outputs, size_t batch_size, bool verbose)

Performs a multi-node multi-GPU [KNN](#namespaceML_1_1KNN) regress. 

* **Parameters:**
  * **handle** – **[in]** the raft::handle_t to use for managing resources 
  * **out** – **[out]** vector of output partitions. size should match the number of local input partitions. 
  * **idx_data** – **[in]** vector of local indices to query 
  * **idx_desc** – **[in]** describes how the index partitions are distributed across the ranks. 
  * **query_data** – **[in]** vector of local query partitions 
  * **query_desc** – **[in]** describes how the query partitions are distributed across the cluster. 
  * **y** – **[in]** vector of vector of output arrays. for multi-output regression, each element in the vector is a different “output” array corresponding to the i’th output. size should match the number of local input partitions. 
  * **rowMajorIndex** – **[in]** boolean indicating whether the index is row major. 
  * **rowMajorQuery** – **[in]** boolean indicating whether the query is row major. 
  * **k** – **[in]** the number of neighbors to query 
  * **n_outputs** – **[in]** number of outputs 
  * **batch_size** – **[in]** the max number of rows to broadcast at a time 
  * **verbose** – **[in]** print extra logging info 

### namespace linkage

### Functions

### void single_linkage(const raft::handle_t &handle, const float \*X, int n_rows, int n_cols, size_t n_clusters, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric, int \*children, int \*labels, float \*distances = nullptr, bool use_knn = false, int c = 15)

Computes single-linkage hierarchical clustering on a dense input feature matrix and outputs the labels, dendrogram, and minimum spanning tree. 

* **Parameters:**
  * **handle** – **[in]** raft handle to encapsulate expensive resources 
  * **X** – **[in]** dense feature matrix on device, C contiguous 
  * **n_rows** – **[in]** number of rows in X 
  * **n_cols** – **[in]** number of columns in X 
  * **n_clusters** – **[in]** the number of clusters to fit. 
  * **metric** – **[in]** distance metric to use. Must be supported by the dense pairwise distances API. 
  * **children** – **[out]** the output dendrogram, shape=(n_rows - 1, 2), C contiguous 
  * **labels** – **[out]** the output labels, shape=(n_rows,) 
  * **distances** – **[out]** optional output of distances between nodes, shape=(n_rows - 1,) 
  * **use_knn** – **[in]** whether to construct a knn graph instead of the full n^2 pairwise distance matrix. This can be faster for very large datasets or in cases where lower memory usage is required. 
  * **c** – **[in]** tunes the number of neighbors when `use_knn` is true, where `n_neighbors=log(n_rows) + c`. 

### namespace matrix

### Enums

### enum class KernelType

*Values:*

### enumerator LINEAR

### enumerator POLYNOMIAL

### enumerator RBF

### enumerator TANH

### enumerator PRECOMPUTED

### Functions

### inline cuvs::distance::kernels::KernelParams to_cuvs([KernelParams](#_CPPv4N2ML6matrix12KernelParamsE) const &config)

### struct KernelParams

 *#include <kernel_params.hpp>*

### namespace Metrics

### Unnamed Group

### double adjusted_rand_index(const raft::handle_t &handle, const int64_t \*y, const int64_t \*y_hat, const int64_t n)

Calculates the “adjusted rand index”

This metric is the corrected-for-chance version of the rand index

* **Parameters:**
  * **handle** – raft::handle_t 
  * **y** – Array of response variables of the first clustering classifications 
  * **y_hat** – Array of response variables of the second clustering classifications 
  * **n** – Number of elements in y and y_hat 
* **Returns:**
  : The adjusted rand index value 

### double adjusted_rand_index(const raft::handle_t &handle, const int \*y, const int \*y_hat, const int n)

### Functions

### float r2_score_py(const raft::handle_t &handle, float \*y, float \*y_hat, int n)

Calculates the “Coefficient of Determination” (R-Squared) score normalizing the sum of squared errors by the total sum of squares with single precision.

This score indicates the proportionate amount of variation in an expected response variable is explained by the independent variables in a linear regression model. The larger the R-squared value, the more variability is explained by the linear regression model.

* **Parameters:**
  * **handle** – raft::handle_t 
  * **y** – Array of ground-truth response variables 
  * **y_hat** – Array of predicted response variables 
  * **n** – Number of elements in y and y_hat 
* **Returns:**
  : The R-squared value. 

### double r2_score_py(const raft::handle_t &handle, double \*y, double \*y_hat, int n)

Calculates the “Coefficient of Determination” (R-Squared) score normalizing the sum of squared errors by the total sum of squares with double precision.

This score indicates the proportionate amount of variation in an expected response variable is explained by the independent variables in a linear regression model. The larger the R-squared value, the more variability is explained by the linear regression model.

* **Parameters:**
  * **handle** – raft::handle_t 
  * **y** – Array of ground-truth response variables 
  * **y_hat** – Array of predicted response variables 
  * **n** – Number of elements in y and y_hat 
* **Returns:**
  : The R-squared value. 

### double rand_index(const raft::handle_t &handle, double \*y, double \*y_hat, int n)

Calculates the “rand index”

This metric is a measure of similarity between two data clusterings.

* **Parameters:**
  * **handle** – raft::handle_t 
  * **y** – Array of response variables of the first clustering classifications 
  * **y_hat** – Array of response variables of the second clustering classifications 
  * **n** – Number of elements in y and y_hat 
* **Returns:**
  : The rand index value 

### double silhouette_score(const raft::handle_t &handle, double \*y, int nRows, int nCols, int \*labels, int nLabels, double \*silScores, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric)

Calculates the “Silhouette Score”

The Silhouette Coefficient is calculated using the mean intra-cluster distance (a) and the mean nearest-cluster distance (b) for each sample. The Silhouette Coefficient for a sample is (b - a) / max(a, b). To clarify, b is the distance between a sample and the nearest cluster that the sample is not a part of. Note that Silhouette Coefficient is only defined if number of labels is 2 <= n_labels <= n_samples - 1.

* **Parameters:**
  * **handle** – raft::handle_t 
  * **y** – Array of data samples with dimensions (nRows x nCols) 
  * **nRows** – number of data samples 
  * **nCols** – number of features 
  * **labels** – Array containing labels for every data sample (1 x nRows) 
  * **nLabels** – number of Labels 
  * **metric** – the numerical value that maps to the type of distance metric to be used in the calculations 
  * **silScores** – Array that is optionally taken in as input if required to be populated with the silhouette score for every sample (1 x nRows), else nullptr is passed 

### double kl_divergence(const raft::handle_t &handle, const double \*y, const double \*y_hat, int n)

Calculates the “Kullback-Leibler Divergence”

The KL divergence tells us how well the probability distribution Q approximates the probability distribution P It is often also used as a ‘distance metric’ between two probability distributions (not symmetric)

* **Parameters:**
  * **handle** – raft::handle_t 
  * **y** – Array of probabilities corresponding to distribution P 
  * **y_hat** – Array of probabilities corresponding to distribution Q 
  * **n** – Number of elements in y and y_hat 
* **Returns:**
  : The KL Divergence value 

### float kl_divergence(const raft::handle_t &handle, const float \*y, const float \*y_hat, int n)

Calculates the “Kullback-Leibler Divergence”

The KL divergence tells us how well the probability distribution Q approximates the probability distribution P It is often also used as a ‘distance metric’ between two probability distributions (not symmetric)

* **Parameters:**
  * **handle** – raft::handle_t 
  * **y** – Array of probabilities corresponding to distribution P 
  * **y_hat** – Array of probabilities corresponding to distribution Q 
  * **n** – Number of elements in y and y_hat 
* **Returns:**
  : The KL Divergence value 

### double entropy(const raft::handle_t &handle, const int \*y, const int n, const int lower_class_range, const int upper_class_range)

Calculates the “entropy” of a labelling

This metric is a measure of the purity/polarity of the clustering

* **Parameters:**
  * **handle** – raft::handle_t 
  * **y** – Array of response variables of the clustering 
  * **n** – Number of elements in y 
  * **lower_class_range** – the lowest value in the range of classes 
  * **upper_class_range** – the highest value in the range of classes 
* **Returns:**
  : The entropy value of the clustering 

### double mutual_info_score(const raft::handle_t &handle, const int \*y, const int \*y_hat, const int n, const int lower_class_range, const int upper_class_range)

Calculates the “Mutual Information score” between two clusters

Mutual Information is a measure of the similarity between two labels of the same data.

* **Parameters:**
  * **handle** – raft::handle_t 
  * **y** – Array of response variables of the first clustering classifications 
  * **y_hat** – Array of response variables of the second clustering classifications 
  * **n** – Number of elements in y and y_hat 
  * **lower_class_range** – the lowest value in the range of classes 
  * **upper_class_range** – the highest value in the range of classes 
* **Returns:**
  : The mutual information score 

### double homogeneity_score(const raft::handle_t &handle, const int \*y, const int \*y_hat, const int n, const int lower_class_range, const int upper_class_range)

Calculates the “homogeneity score” between two clusters

A clustering result satisfies homogeneity if all of its clusters contain only data points which are members of a single class.

* **Parameters:**
  * **handle** – raft::handle_t 
  * **y** – truth labels 
  * **y_hat** – predicted labels 
  * **n** – Number of elements in y and y_hat 
  * **lower_class_range** – the lowest value in the range of classes 
  * **upper_class_range** – the highest value in the range of classes 
* **Returns:**
  : The homogeneity score 

### double completeness_score(const raft::handle_t &handle, const int \*y, const int \*y_hat, const int n, const int lower_class_range, const int upper_class_range)

Calculates the “completeness score” between two clusters

A clustering result satisfies completeness if all the data points that are members of a given class are elements of the same cluster.

* **Parameters:**
  * **handle** – raft::handle_t 
  * **y** – truth labels 
  * **y_hat** – predicted labels 
  * **n** – Number of elements in y and y_hat 
  * **lower_class_range** – the lowest value in the range of classes 
  * **upper_class_range** – the highest value in the range of classes 
* **Returns:**
  : The completeness score 

### double v_measure(const raft::handle_t &handle, const int \*y, const int \*y_hat, const int n, const int lower_class_range, const int upper_class_range, double beta)

Calculates the “v-measure” between two clusters

v-measure is the harmonic mean between the homogeneity and completeness scores of 2 cluster classifications

* **Parameters:**
  * **handle** – raft::handle_t 
  * **y** – truth labels 
  * **y_hat** – predicted labels 
  * **n** – Number of elements in y and y_hat 
  * **lower_class_range** – the lowest value in the range of classes 
  * **upper_class_range** – the highest value in the range of classes 
  * **beta** – Ratio of weight attributed to homogeneity vs completeness 
* **Returns:**
  : The v-measure 

### float accuracy_score_py(const raft::handle_t &handle, const int \*predictions, const int \*ref_predictions, int n)

Calculates the “accuracy” between two input numpy arrays/ cudf series

The accuracy metric is used to calculate the accuracy of the predict labels predict labels

* **Parameters:**
  * **handle** – raft::handle_t 
  * **predictions** – predicted labels 
  * **ref_predictions** – truth labels 
  * **n** – Number of elements in y and y_hat 
* **Returns:**
  : The accuracy 

### void pairwise_distance(const raft::handle_t &handle, const double \*x, const double \*y, double \*dist, int m, int n, int k, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric, bool isRowMajor = true, double metric_arg = 2.0)

Calculates the ij pairwise distances between two input arrays of double type. 

* **Parameters:**
  * **handle** – raft::handle_t 
  * **x** – pointer to the input data samples array (mRows x kCols) 
  * **y** – pointer to the second input data samples array. Can use the same pointer as x (nRows x kCols) 
  * **dist** – output pointer where the results will be stored (mRows x nCols) 
  * **m** – number of rows in x 
  * **n** – number of rows in y 
  * **k** – number of cols in x and y (must be the same) 
  * **metric** – the distance metric to use for the calculation 
  * **isRowMajor** – specifies whether the x and y data pointers are row (C type array) or col (F type array) major 
  * **metric_arg** – the value of `p` for Minkowski (l-p) distances. 

### void pairwise_distance(const raft::handle_t &handle, const float \*x, const float \*y, float \*dist, int m, int n, int k, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric, bool isRowMajor = true, float metric_arg = 2.0f)

Calculates the ij pairwise distances between two input arrays of float type. 

* **Parameters:**
  * **handle** – raft::handle_t 
  * **x** – pointer to the input data samples array (mRows x kCols) 
  * **y** – pointer to the second input data samples array. Can use the same pointer as x (nRows x kCols) 
  * **dist** – output pointer where the results will be stored (mRows x nCols) 
  * **m** – number of rows in x 
  * **n** – number of rows in y 
  * **k** – number of cols in x and y (must be the same) 
  * **metric** – the distance metric to use for the calculation 
  * **isRowMajor** – specifies whether the x and y data pointers are row (C type array) or col (F type array) major 
  * **metric_arg** – the value of `p` for Minkowski (l-p) distances. 

### void pairwiseDistance_sparse(const raft::handle_t &handle, double \*x, double \*y, double \*dist, int x_nrows, int y_nrows, int n_cols, int x_nnz, int y_nnz, int \*x_indptr, int \*y_indptr, int \*x_indices, int \*y_indices, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric, float metric_arg)

### void pairwiseDistance_sparse(const raft::handle_t &handle, float \*x, float \*y, float \*dist, int x_nrows, int y_nrows, int n_cols, int x_nnz, int y_nnz, int \*x_indptr, int \*y_indptr, int \*x_indices, int \*y_indices, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric, float metric_arg)

### template<typename math_t, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) distance_type>double trustworthiness_score(const raft::handle_t &h, const [math_t](#_CPPv4I0_N2ML8distance12DistanceTypeEEN2ML7Metrics21trustworthiness_scoreEdRKN4raft8handle_tEPK6math_tP6math_tiiiii) \*X, [math_t](#_CPPv4I0_N2ML8distance12DistanceTypeEEN2ML7Metrics21trustworthiness_scoreEdRKN4raft8handle_tEPK6math_tP6math_tiiiii) \*X_embedded, int n, int m, int d, int n_neighbors, int batchSize = 512)

Compute the trustworthiness score. 

* **Parameters:**
  * **h** – Raft handle 
  * **X** – Data in original dimension 
  * **X_embedded** – Data in target dimension (embedding) 
  * **n** – Number of samples 
  * **m** – Number of features in high/original dimension 
  * **d** – Number of features in low/embedded dimension 
  * **n_neighbors** – Number of neighbors considered by trustworthiness score 
  * **batchSize** – Batch size 
* **Template Parameters:**
  **distance_type** – Distance type to consider 
* **Returns:**
  Trustworthiness score 

### namespace Batched

### Functions

### float silhouette_score(const raft::handle_t &handle, float \*X, int n_rows, int n_cols, int \*y, int n_labels, float \*scores, int chunk, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric)

Calculates [Batched](#namespaceML_1_1Metrics_1_1Batched) “Silhouette Score” by tiling the pairwise distance matrix to remove use of quadratic memory

The Silhouette Coefficient is calculated using the mean intra-cluster distance (a) and the mean nearest-cluster distance (b) for each sample. The Silhouette Coefficient for a sample is (b - a) / max(a, b). To clarify, b is the distance between a sample and the nearest cluster that the sample is not a part of. Note that Silhouette Coefficient is only defined if number of labels is 2 <= n_labels <= n_samples - 1.

* **Parameters:**
  * **handle** – **[in]** raft::handle_t 
  * **X** – **[in]** Array of data samples with dimensions (n_rows x n_cols) 
  * **n_rows** – **[in]** number of data samples 
  * **n_cols** – **[in]** number of features 
  * **y** – **[in]** Array containing labels for every data sample (1 x n_rows) 
  * **n_labels** – **[in]** number of Labels 
  * **metric** – **[in]** the numerical value that maps to the type of distance metric to be used in the calculations 
  * **chunk** – **[in]** the row-wise chunk size on which the pairwise distance matrix is tiled 
  * **scores** – **[out]** Array that is optionally taken in as input if required to be populated with the silhouette score for every sample (1 x nRows), else nullptr is passed 

### double silhouette_score(const raft::handle_t &handle, double \*X, int n_rows, int n_cols, int \*y, int n_labels, double \*scores, int chunk, [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric)

### namespace OLS

### namespace opg

### Functions

### void fit(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> &labels, float \*coef, float \*intercept, bool fit_intercept, int algo, bool verbose)

performs MNMG fit operation for the ridge regression 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **input_data** – **[in]** vector holding all partitions for that rank 
  * **input_desc** – **[in]** PartDescriptor object for the input 
  * **labels** – **[in]** labels data 
  * **coef** – **[out]** learned regression coefficients 
  * **intercept** – **[out]** intercept value 
  * **fit_intercept** – **[in]** fit intercept or not 
  * **algo** – **[in]** which algorithm is used for [OLS](#namespaceML_1_1OLS). 0 is for SVD, 1 is for eig. 
  * **verbose** – **[in]** 

### void fit(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double>\*> &labels, double \*coef, double \*intercept, bool fit_intercept, int algo, bool verbose)

### void predict(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, size_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*input, size_t n_rows, size_t n_cols, float \*coef, float intercept, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*preds, bool verbose)

performs MNMG prediction for [OLS](#namespaceML_1_1OLS)

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **rank_sizes** – **[in]** includes all the partition size information for the rank 
  * **n_parts** – **[in]** number of partitions 
  * **input** – **[in]** input data 
  * **n_rows** – **[in]** number of rows of input data 
  * **n_cols** – **[in]** number of cols of input data 
  * **coef** – **[in]** [OLS](#namespaceML_1_1OLS) coefficients 
  * **intercept** – **[in]** the fit intercept 
  * **preds** – **[out]** predictions 
  * **verbose** – **[in]** 

### void predict(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, size_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*input, size_t n_rows, size_t n_cols, double \*coef, double intercept, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*preds, bool verbose)

### namespace PCA

### namespace opg

### Functions

### void fit(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, float \*components, float \*explained_var, float \*explained_var_ratio, float \*singular_vals, float \*mu, float \*noise_vars, [paramsPCAMG](#_CPPv4N2ML11paramsPCAMGE) prms, bool verbose = false)

performs MNMG fit operation for the pca 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **input_data** – **[in]** input data 
  * **input_desc** – **[in]** descriptor for input data 
  * **components** – **[out]** principal components of the input data 
  * **explained_var** – **[out]** explained var 
  * **explained_var_ratio** – **[out]** the explained var ratio 
  * **singular_vals** – **[out]** singular values of the data 
  * **mu** – **[out]** mean of every column in input 
  * **noise_vars** – **[out]** variance of the noise 
  * **prms** – **[in]** data structure that includes all the parameters from input size to algorithm 
  * **verbose** – **[in]** 

### void fit(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, double \*components, double \*explained_var, double \*explained_var_ratio, double \*singular_vals, double \*mu, double \*noise_vars, [paramsPCAMG](#_CPPv4N2ML11paramsPCAMGE) prms, bool verbose = false)

### void fit_transform(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, std::uint32_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[floatData_t](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix11floatData_tE) \*\*input, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[floatData_t](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix11floatData_tE) \*\*trans_input, float \*components, float \*explained_var, float \*explained_var_ratio, float \*singular_vals, float \*mu, float \*noise_vars, [paramsPCAMG](#_CPPv4N2ML11paramsPCAMGE) prms, bool verbose)

performs MNMG fit and transform operation for the pca 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **rank_sizes** – **[in]** includes all the partition size information for the rank 
  * **n_parts** – **[in]** number of partitions 
  * **input** – **[in]** input data 
  * **trans_input** – **[out]** transformed input data 
  * **components** – **[out]** principal components of the input data 
  * **explained_var** – **[out]** explained var 
  * **explained_var_ratio** – **[out]** the explained var ratio 
  * **singular_vals** – **[out]** singular values of the data 
  * **mu** – **[out]** mean of every column in input 
  * **noise_vars** – **[out]** variance of the noise 
  * **prms** – **[in]** data structure that includes all the parameters from input size to algorithm 
  * **verbose** – **[in]** 

### void fit_transform(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, std::uint32_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[doubleData_t](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12doubleData_tE) \*\*input, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[doubleData_t](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12doubleData_tE) \*\*trans_input, double \*components, double \*explained_var, double \*explained_var_ratio, double \*singular_vals, double \*mu, double \*noise_vars, [paramsPCAMG](#_CPPv4N2ML11paramsPCAMGE) prms, bool verbose)

### void transform(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, std::uint32_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*input, float \*components, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*trans_input, float \*singular_vals, float \*mu, [paramsPCAMG](#_CPPv4N2ML11paramsPCAMGE) prms, bool verbose)

performs MNMG transform operation for the pca 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **rank_sizes** – **[in]** includes all the partition size information for the rank 
  * **n_parts** – **[in]** number of partitions 
  * **input** – **[in]** input data 
  * **components** – **[in]** principal components of the input data 
  * **trans_input** – **[out]** transformed input data 
  * **singular_vals** – **[in]** singular values of the data 
  * **mu** – **[in]** mean of every column in input 
  * **prms** – **[in]** data structure that includes all the parameters from input size to algorithm 
  * **verbose** – **[in]** 

### void transform(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, std::uint32_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*input, double \*components, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*trans_input, double \*singular_vals, double \*mu, [paramsPCAMG](#_CPPv4N2ML11paramsPCAMGE) prms, bool verbose)

### void inverse_transform(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, std::uint32_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*trans_input, float \*components, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*input, float \*singular_vals, float \*mu, [paramsPCAMG](#_CPPv4N2ML11paramsPCAMGE) prms, bool verbose)

performs MNMG inverse transform operation for the pca 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **rank_sizes** – **[in]** includes all the partition size information for the rank 
  * **n_parts** – **[in]** number of partitions 
  * **trans_input** – **[in]** transformed input data 
  * **components** – **[in]** principal components of the input data 
  * **input** – **[out]** input data 
  * **singular_vals** – **[in]** singular values of the data 
  * **mu** – **[in]** mean of every column in input 
  * **prms** – **[in]** data structure that includes all the parameters from input size to algorithm 
  * **verbose** – **[in]** 

### void inverse_transform(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, std::uint32_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*trans_input, double \*components, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*input, double \*singular_vals, double \*mu, [paramsPCAMG](#_CPPv4N2ML11paramsPCAMGE) prms, bool verbose)

### namespace Ridge

### namespace opg

### Functions

### void fit(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> &labels, float \*alpha, int n_alpha, float \*coef, float \*intercept, bool fit_intercept, int algo, bool verbose)

performs MNMG fit operation for the ridge regression 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **input_data** – **[in]** vector holding all partitions for that rank 
  * **input_desc** – **[in]** PartDescriptor object for the input 
  * **labels** – **[in]** labels data 
  * **alpha** – **[in]** ridge parameter 
  * **n_alpha** – **[in]** number of ridge parameters. Only one parameter is supported right now. 
  * **coef** – **[out]** learned regression coefficients 
  * **intercept** – **[out]** intercept value 
  * **fit_intercept** – **[in]** fit intercept or not 
  * **algo** – **[in]** the algorithm to use for fitting 
  * **verbose** – **[in]** 

### void fit(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double>\*> &labels, double \*alpha, int n_alpha, double \*coef, double \*intercept, bool fit_intercept, int algo, bool verbose)

### void predict(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, size_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*input, size_t n_rows, size_t n_cols, float \*coef, float intercept, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*preds, bool verbose)

performs MNMG prediction for [OLS](#namespaceML_1_1OLS)

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **rank_sizes** – **[in]** includes all the partition size information for the rank 
  * **n_parts** – **[in]** number of partitions 
  * **input** – **[in]** input data 
  * **n_rows** – **[in]** number of rows of input data 
  * **n_cols** – **[in]** number of cols of input data 
  * **coef** – **[in]** [OLS](#namespaceML_1_1OLS) coefficients 
  * **intercept** – **[in]** the fit intercept 
  * **preds** – **[out]** predictions 
  * **verbose** – **[in]** 

### void predict(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, size_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*input, size_t n_rows, size_t n_cols, double \*coef, double intercept, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*preds, bool verbose)

### namespace Solver

### Functions

### void sgdFit(raft::handle_t &handle, float \*input, int n_rows, int n_cols, float \*labels, float \*coef, float \*intercept, bool fit_intercept, int batch_size, int epochs, int lr_type, float eta0, float power_t, int loss, int penalty, float alpha, float l1_ratio, bool shuffle, float tol, int n_iter_no_change)

### void sgdFit(raft::handle_t &handle, double \*input, int n_rows, int n_cols, double \*labels, double \*coef, double \*intercept, bool fit_intercept, int batch_size, int epochs, int lr_type, double eta0, double power_t, int loss, int penalty, double alpha, double l1_ratio, bool shuffle, double tol, int n_iter_no_change)

### void sgdPredict(raft::handle_t &handle, const float \*input, int n_rows, int n_cols, const float \*coef, float intercept, float \*preds, int loss)

### void sgdPredict(raft::handle_t &handle, const double \*input, int n_rows, int n_cols, const double \*coef, double intercept, double \*preds, int loss)

### void sgdPredictBinaryClass(raft::handle_t &handle, const float \*input, int n_rows, int n_cols, const float \*coef, float intercept, float \*preds, int loss)

### void sgdPredictBinaryClass(raft::handle_t &handle, const double \*input, int n_rows, int n_cols, const double \*coef, double intercept, double \*preds, int loss)

### int cdFit(raft::handle_t &handle, float \*input, int n_rows, int n_cols, float \*labels, float \*coef, float \*intercept, bool fit_intercept, int epochs, int loss, float alpha, float l1_ratio, bool shuffle, float tol, float \*sample_weight = nullptr)

Fits a linear, lasso, and elastic-net regression model using Coordinate Descent solver.

i.e. finds coefficients that minimize the following loss function:

f(coef) = 1/2 \* || labels - input \* coef ||^2
* 1/2 \* alpha \* (1 - l1_ratio) \* ||coef||^2
* alpha \* l1_ratio \* ||coef||_1

* **Parameters:**
  * **handle** – Reference of raft::handle_t 
  * **input** – pointer to an array in column-major format (size of n_rows, n_cols) 
  * **n_rows** – n_samples or rows in input 
  * **n_cols** – n_features or columns in X 
  * **labels** – pointer to an array for labels (size of n_rows) 
  * **coef** – pointer to an array for coefficients (size of n_cols). This will be filled with coefficients once the function is executed. 
  * **intercept** – pointer to a scalar for intercept. This will be filled once the function is executed 
  * **fit_intercept** – boolean parameter to control if the intercept will be fitted or not 
  * **epochs** – Maximum number of iterations that solver will run 
  * **loss** – enum to use different loss functions. Only linear regression loss functions is supported right now 
  * **alpha** – L1 parameter 
  * **l1_ratio** – ratio of alpha will be used for L1. (1 - l1_ratio) \* alpha will be used for L2 
  * **shuffle** – boolean parameter to control whether coordinates will be picked randomly or not 
  * **tol** – tolerance to stop the solver 
  * **sample_weight** – device pointer to sample weight vector of length n_rows (nullptr or uniform weights) This vector is modified during the computation 
* **Returns:**
  n_iter Number of iterations the solver ran for. 

### int cdFit(raft::handle_t &handle, double \*input, int n_rows, int n_cols, double \*labels, double \*coef, double \*intercept, bool fit_intercept, int epochs, int loss, double alpha, double l1_ratio, bool shuffle, double tol, double \*sample_weight = nullptr)

### void cdPredict(raft::handle_t &handle, const float \*input, int n_rows, int n_cols, const float \*coef, float intercept, float \*preds, int loss)

### void cdPredict(raft::handle_t &handle, const double \*input, int n_rows, int n_cols, const double \*coef, double intercept, double \*preds, int loss)

### template<typename math_t>[math_t](#_CPPv4I0EN2ML6Solver3maxE6math_t6math_t6math_t) max([math_t](#_CPPv4I0EN2ML6Solver3maxE6math_t6math_t6math_t) a, [math_t](#_CPPv4I0EN2ML6Solver3maxE6math_t6math_t6math_t) b)

### template<typename math_t>[math_t](#_CPPv4I0EN2ML6Solver10invScalingE6math_t6math_t6math_ti) invScaling([math_t](#_CPPv4I0EN2ML6Solver10invScalingE6math_t6math_t6math_ti) eta, [math_t](#_CPPv4I0EN2ML6Solver10invScalingE6math_t6math_t6math_ti) power_t, int t)

### template<typename math_t>[math_t](#_CPPv4I0EN2ML6Solver8regDLossE6math_t6math_t6math_t) regDLoss([math_t](#_CPPv4I0EN2ML6Solver8regDLossE6math_t6math_t6math_t) a, [math_t](#_CPPv4I0EN2ML6Solver8regDLossE6math_t6math_t6math_t) b)

### template<typename math_t>[math_t](#_CPPv4I0EN2ML6Solver14calOptimalInitE6math_t6math_t) calOptimalInit([math_t](#_CPPv4I0EN2ML6Solver14calOptimalInitE6math_t6math_t) alpha)

### template<typename math_t>[math_t](#_CPPv4I0EN2ML6Solver7optimalE6math_t6math_t6math_ti) optimal([math_t](#_CPPv4I0EN2ML6Solver7optimalE6math_t6math_t6math_ti) alpha, [math_t](#_CPPv4I0EN2ML6Solver7optimalE6math_t6math_t6math_ti) optimal_init, int t)

### template<typename math_t>[math_t](#_CPPv4I0EN2ML6Solver15calLearningRateE6math_tN2ML7lr_typeE6math_t6math_t6math_t6math_t) calLearningRate([ML](#_CPPv42ML)::[lr_type](#_CPPv4N2ML7lr_typeE) lr_type, [math_t](#_CPPv4I0EN2ML6Solver15calLearningRateE6math_tN2ML7lr_typeE6math_t6math_t6math_t6math_t) eta, [math_t](#_CPPv4I0EN2ML6Solver15calLearningRateE6math_tN2ML7lr_typeE6math_t6math_t6math_t6math_t) power_t, [math_t](#_CPPv4I0EN2ML6Solver15calLearningRateE6math_tN2ML7lr_typeE6math_t6math_t6math_t6math_t) alpha, [math_t](#_CPPv4I0EN2ML6Solver15calLearningRateE6math_tN2ML7lr_typeE6math_t6math_t6math_t6math_t) t)

### template<typename math_t>void initShuffle(std::vector<[math_t](#_CPPv4I0EN2ML6Solver11initShuffleEvRNSt6vectorI6math_tEERNSt7mt19937E6math_t)> &rand_indices, std::mt19937 &g, [math_t](#_CPPv4I0EN2ML6Solver11initShuffleEvRNSt6vectorI6math_tEERNSt7mt19937E6math_t) random_state = 0)

### template<typename math_t>void shuffle(std::vector<[math_t](#_CPPv4I0EN2ML6Solver7shuffleEvRNSt6vectorI6math_tEERNSt7mt19937E)> &rand_indices, std::mt19937 &g)

### namespace Lars

### Functions

### template<typename math_t, typename idx_t>void larsFit(const raft::handle_t &handle, [math_t](#_CPPv4I00EN2ML6Solver4Lars7larsFitEvRKN4raft8handle_tEP6math_t5idx_t5idx_tPK6math_tP6math_tP5idx_tP6math_tP5idx_tP6math_tiP6math_tN13rapids_logger10level_enumE5idx_t5idx_t6math_t) \*X, [idx_t](#_CPPv4I00EN2ML6Solver4Lars7larsFitEvRKN4raft8handle_tEP6math_t5idx_t5idx_tPK6math_tP6math_tP5idx_tP6math_tP5idx_tP6math_tiP6math_tN13rapids_logger10level_enumE5idx_t5idx_t6math_t) n_rows, [idx_t](#_CPPv4I00EN2ML6Solver4Lars7larsFitEvRKN4raft8handle_tEP6math_t5idx_t5idx_tPK6math_tP6math_tP5idx_tP6math_tP5idx_tP6math_tiP6math_tN13rapids_logger10level_enumE5idx_t5idx_t6math_t) n_cols, const [math_t](#_CPPv4I00EN2ML6Solver4Lars7larsFitEvRKN4raft8handle_tEP6math_t5idx_t5idx_tPK6math_tP6math_tP5idx_tP6math_tP5idx_tP6math_tiP6math_tN13rapids_logger10level_enumE5idx_t5idx_t6math_t) \*y, [math_t](#_CPPv4I00EN2ML6Solver4Lars7larsFitEvRKN4raft8handle_tEP6math_t5idx_t5idx_tPK6math_tP6math_tP5idx_tP6math_tP5idx_tP6math_tiP6math_tN13rapids_logger10level_enumE5idx_t5idx_t6math_t) \*beta, [idx_t](#_CPPv4I00EN2ML6Solver4Lars7larsFitEvRKN4raft8handle_tEP6math_t5idx_t5idx_tPK6math_tP6math_tP5idx_tP6math_tP5idx_tP6math_tiP6math_tN13rapids_logger10level_enumE5idx_t5idx_t6math_t) \*active_idx, [math_t](#_CPPv4I00EN2ML6Solver4Lars7larsFitEvRKN4raft8handle_tEP6math_t5idx_t5idx_tPK6math_tP6math_tP5idx_tP6math_tP5idx_tP6math_tiP6math_tN13rapids_logger10level_enumE5idx_t5idx_t6math_t) \*alphas, [idx_t](#_CPPv4I00EN2ML6Solver4Lars7larsFitEvRKN4raft8handle_tEP6math_t5idx_t5idx_tPK6math_tP6math_tP5idx_tP6math_tP5idx_tP6math_tiP6math_tN13rapids_logger10level_enumE5idx_t5idx_t6math_t) \*n_active, [math_t](#_CPPv4I00EN2ML6Solver4Lars7larsFitEvRKN4raft8handle_tEP6math_t5idx_t5idx_tPK6math_tP6math_tP5idx_tP6math_tP5idx_tP6math_tiP6math_tN13rapids_logger10level_enumE5idx_t5idx_t6math_t) \*Gram = nullptr, int max_iter = 500, [math_t](#_CPPv4I00EN2ML6Solver4Lars7larsFitEvRKN4raft8handle_tEP6math_t5idx_t5idx_tPK6math_tP6math_tP5idx_tP6math_tP5idx_tP6math_tiP6math_tN13rapids_logger10level_enumE5idx_t5idx_t6math_t) \*coef_path = nullptr, rapids_logger::level_enum verbosity = rapids_logger::level_enum::off, [idx_t](#_CPPv4I00EN2ML6Solver4Lars7larsFitEvRKN4raft8handle_tEP6math_t5idx_t5idx_tPK6math_tP6math_tP5idx_tP6math_tP5idx_tP6math_tiP6math_tN13rapids_logger10level_enumE5idx_t5idx_t6math_t) ld_X = 0, [idx_t](#_CPPv4I00EN2ML6Solver4Lars7larsFitEvRKN4raft8handle_tEP6math_t5idx_t5idx_tPK6math_tP6math_tP5idx_tP6math_tP5idx_tP6math_tiP6math_tN13rapids_logger10level_enumE5idx_t5idx_t6math_t) ld_G = 0, [math_t](#_CPPv4I00EN2ML6Solver4Lars7larsFitEvRKN4raft8handle_tEP6math_t5idx_t5idx_tPK6math_tP6math_tP5idx_tP6math_tP5idx_tP6math_tiP6math_tN13rapids_logger10level_enumE5idx_t5idx_t6math_t) eps = -1)

Train a regressor using LARS method. 

* **Parameters:**
  * **handle** – RAFT handle 
  * **X** – device array of training vectors in column major format, size [n_rows \* n_cols]. Note that the columns of X will be permuted if the Gram matrix is not specified. It is expected that X is normalized so that each column has zero mean and unit variance. 
  * **n_rows** – number of training samples 
  * **n_cols** – number of feature columns 
  * **y** – device array of the regression targets, size [n_rows]. y should be normalized to have zero mean. 
  * **beta** – device array of regression coefficients, has to be allocated on entry, size [max_iter] 
  * **active_idx** – device array containing the indices of active variables. Must be allocated on entry. Size [max_iter] 
  * **alphas** – the maximum correlation along the regularization path are returned here. Must be a device array allocated on entry Size [max_iter]. 
  * **n_active** – host pointer to return the number of active elements, scalar. 
  * **Gram** – device array containing Gram matrix (X.T \* X). Can be nullptr. Size [n_cols \* ld_G] 
  * **max_iter** – maximum number of iterations, this equals with the maximum number of coefficients returned. max_iter <= n_cols. 
  * **coef_path** – coefficients along the regularization path are returned here. Must be nullptr, or a device array already allocated on entry. Size [max_iter \* max_iter]. 
  * **verbosity** – verbosity level 
  * **ld_X** – leading dimension of X (stride of columns, ld_X >= n_rows). 
  * **ld_G** – leading dimension of G (ld_G >= n_cols) 
  * **eps** – numeric parameter for Cholesky rank one update 

### template<typename math_t, typename idx_t>void larsPredict(const raft::handle_t &handle, const [math_t](#_CPPv4I00EN2ML6Solver4Lars11larsPredictEvRKN4raft8handle_tEPK6math_t5idx_t5idx_t5idx_tPK6math_t5idx_tP5idx_t6math_tP6math_t) \*X, [idx_t](#_CPPv4I00EN2ML6Solver4Lars11larsPredictEvRKN4raft8handle_tEPK6math_t5idx_t5idx_t5idx_tPK6math_t5idx_tP5idx_t6math_tP6math_t) n_rows, [idx_t](#_CPPv4I00EN2ML6Solver4Lars11larsPredictEvRKN4raft8handle_tEPK6math_t5idx_t5idx_t5idx_tPK6math_t5idx_tP5idx_t6math_tP6math_t) n_cols, [idx_t](#_CPPv4I00EN2ML6Solver4Lars11larsPredictEvRKN4raft8handle_tEPK6math_t5idx_t5idx_t5idx_tPK6math_t5idx_tP5idx_t6math_tP6math_t) ld_X, const [math_t](#_CPPv4I00EN2ML6Solver4Lars11larsPredictEvRKN4raft8handle_tEPK6math_t5idx_t5idx_t5idx_tPK6math_t5idx_tP5idx_t6math_tP6math_t) \*beta, [idx_t](#_CPPv4I00EN2ML6Solver4Lars11larsPredictEvRKN4raft8handle_tEPK6math_t5idx_t5idx_t5idx_tPK6math_t5idx_tP5idx_t6math_tP6math_t) n_active, [idx_t](#_CPPv4I00EN2ML6Solver4Lars11larsPredictEvRKN4raft8handle_tEPK6math_t5idx_t5idx_t5idx_tPK6math_t5idx_tP5idx_t6math_tP6math_t) \*active_idx, [math_t](#_CPPv4I00EN2ML6Solver4Lars11larsPredictEvRKN4raft8handle_tEPK6math_t5idx_t5idx_t5idx_tPK6math_t5idx_tP5idx_t6math_tP6math_t) intercept, [math_t](#_CPPv4I00EN2ML6Solver4Lars11larsPredictEvRKN4raft8handle_tEPK6math_t5idx_t5idx_t5idx_tPK6math_t5idx_tP5idx_t6math_tP6math_t) \*preds)

Predict with LARS regressor. 

* **Parameters:**
  * **handle** – RAFT handle 
  * **X** – device array of training vectors in column major format, size [n_rows \* n_cols]. 
  * **n_rows** – number of training samples 
  * **n_cols** – number of feature columns 
  * **ld_X** – leading dimension of X (stride of columns) 
  * **beta** – device array of regression coefficients, size [n_active] 
  * **n_active** – the number of regression coefficients 
  * **active_idx** – device array containing the indices of active variables. Only these columns of X will be used for prediction, size [n_active]. 
  * **intercept** – 
  * **preds** – device array to store the predictions, size [n_rows]. Must be allocated on entry. 

### namespace Sparse

### Functions

### void brute_force_knn(raft::handle_t &handle, const int \*idx_indptr, const int \*idx_indices, const float \*idx_data, size_t idx_nnz, int n_idx_rows, int n_idx_cols, const int \*query_indptr, const int \*query_indices, const float \*query_data, size_t query_nnz, int n_query_rows, int n_query_cols, int \*output_indices, float \*output_dists, int k, size_t batch_size_index = [DEFAULT_BATCH_SIZE](#_CPPv4N2ML6Sparse18DEFAULT_BATCH_SIZEE), size_t batch_size_query = [DEFAULT_BATCH_SIZE](#_CPPv4N2ML6Sparse18DEFAULT_BATCH_SIZEE), [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE) metric = [ML](#_CPPv42ML)::[distance](#_CPPv4N2ML8distanceE)::[DistanceType](#_CPPv4N2ML8distance12DistanceTypeE)::[L2Expanded](#_CPPv4N2ML8distance12DistanceType10L2ExpandedE), float metricArg = 0)

### Variables

### constexpr int DEFAULT_BATCH_SIZE = 1 << 16

### namespace SpectralClustering

### Functions

### void fit_predict(raft::resources const &handle, [params](#_CPPv4N2ML18SpectralClustering6paramsE) config, raft::device_matrix_view<float, int, raft::row_major> dataset, raft::device_vector_view<int, int> labels)

Perform spectral clustering on input dataset by constructing a k-nearest neighbors graph. 

* **Parameters:**
  * **handle** – **[in]** cuML resources handle 
  * **config** – **[in]** Parameters for spectral clustering 
  * **dataset** – **[in]** Input dataset (row-major) 
  * **labels** – **[out]** Cluster labels for each sample 

### void fit_predict(raft::resources const &handle, [params](#_CPPv4N2ML18SpectralClustering6paramsE) config, raft::device_coo_matrix_view<float, int, int, int> connectivity_graph, raft::device_vector_view<int, int> labels)

Perform spectral clustering on a precomputed connectivity graph using COO sparse matrix view. 

* **Parameters:**
  * **handle** – **[in]** cuML resources handle 
  * **config** – **[in]** Parameters for spectral clustering 
  * **connectivity_graph** – **[in]** COO sparse matrix view of the connectivity graph 
  * **labels** – **[out]** Cluster labels for each sample 

### void fit_predict(raft::resources const &handle, [params](#_CPPv4N2ML18SpectralClustering6paramsE) config, raft::device_vector_view<int, int> rows, raft::device_vector_view<int, int> cols, raft::device_vector_view<float, int> vals, raft::device_vector_view<int, int> labels)

Perform spectral clustering on a precomputed connectivity graph using separate vector views for COO components. 

* **Parameters:**
  * **handle** – **[in]** cuML resources handle 
  * **config** – **[in]** Parameters for spectral clustering 
  * **rows** – **[in]** Row indices of the COO sparse matrix 
  * **cols** – **[in]** Column indices of the COO sparse matrix 
  * **vals** – **[in]** Values of the COO sparse matrix 
  * **labels** – **[out]** Cluster labels for each sample 

### struct params

 *#include <spectral_clustering.hpp>*

Spectral clustering parameters. 

### Public Members

### int n_clusters

Number of clusters to find. 

### int n_components

Number of eigenvectors to use. 

### int n_init

Number of times to run k-means with different seeds. 

### int n_neighbors

Number of neighbors for kNN graph construction. 

### float eigen_tol

Tolerance for the eigensolver. 

### uint64_t seed

Random seed for reproducibility. 

### namespace SpectralEmbedding

### Functions

### void transform(raft::resources const &handle, [ML](#_CPPv42ML)::[SpectralEmbedding](#_CPPv4N2ML17SpectralEmbeddingE)::[params](#_CPPv4N2ML17SpectralEmbedding6paramsE) config, raft::device_matrix_view<float, int, raft::row_major> dataset, raft::device_matrix_view<float, int, raft::col_major> embedding)

### void transform(raft::resources const &handle, [ML](#_CPPv42ML)::[SpectralEmbedding](#_CPPv4N2ML17SpectralEmbeddingE)::[params](#_CPPv4N2ML17SpectralEmbedding6paramsE) config, raft::device_coo_matrix_view<float, int, int, int64_t> connectivity_graph, raft::device_matrix_view<float, int, raft::col_major> embedding)

### void transform(raft::resources const &handle, [ML](#_CPPv42ML)::[SpectralEmbedding](#_CPPv4N2ML17SpectralEmbeddingE)::[params](#_CPPv4N2ML17SpectralEmbedding6paramsE) config, raft::device_vector_view<int, int64_t> rows, raft::device_vector_view<int, int64_t> cols, raft::device_vector_view<float, int64_t> vals, raft::device_matrix_view<float, int, raft::col_major> embedding)

### inline cuvs::preprocessing::spectral_embedding::params to_cuvs([params](#_CPPv4N2ML17SpectralEmbedding6paramsE) const &config)

### struct params

 *#include <spectral_embedding.hpp>*

Parameters for spectral embedding algorithm. 

### Public Members

### int n_components

The number of components to reduce the data to. 

### int n_neighbors

The number of neighbors to use for the nearest neighbors graph. 

### bool norm_laplacian

Whether to normalize the Laplacian matrix. 

### bool drop_first

Whether to drop the first eigenvector. 

### std::optional<uint64_t> seed = std::nullopt

Random seed for reproducibility. 

### namespace SVM

### Enums

### enum SvmType

*Values:*

### enumerator C_SVC

### enumerator NU_SVC

### enumerator EPSILON_SVR

### enumerator NU_SVR

### Functions

### template<typename math_t>int svcFit(const raft::handle_t &handle, [math_t](#_CPPv4I0EN2ML3SVM6svcFitEiRKN4raft8handle_tEP6math_tiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t) \*input, int n_rows, int n_cols, [math_t](#_CPPv4I0EN2ML3SVM6svcFitEiRKN4raft8handle_tEP6math_tiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t) \*labels, const [SvmParameter](#_CPPv4N2ML3SVM12SvmParameterE) &param, [ML](#_CPPv42ML)::[matrix](#_CPPv4N2ML6matrixE)::[KernelParams](#_CPPv4N2ML6matrix12KernelParamsE) &kernel_params, [SvmModel](#_CPPv4I0EN2ML3SVM8SvmModelE)<[math_t](#_CPPv4I0EN2ML3SVM6svcFitEiRKN4raft8handle_tEP6math_tiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t)> &model, const [math_t](#_CPPv4I0EN2ML3SVM6svcFitEiRKN4raft8handle_tEP6math_tiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t) \*sample_weight)

Fit a support vector classifier to the training data. 

Each row of the input data stores a feature vector. We use the SMO method to fit the [SVM](#namespaceML_1_1SVM).

The output device buffers in model shall be unallocated on entry.

* **Template Parameters:**
  **math_t** – floating point type 
* **Parameters:**
  * **handle** – **[in]** the cuML handle 
  * **input** – **[in]** device pointer for the input data in column major format. Size n_rows x n_cols. 
  * **n_rows** – **[in]** number of rows 
  * **n_cols** – **[in]** number of columns 
  * **labels** – **[in]** device pointer for the labels. Size [n_rows]. 
  * **param** – **[in]** parameters for training 
  * **kernel_params** – **[in]** parameters for the kernel function 
  * **model** – **[out]** parameters of the trained model 
  * **sample_weight** – **[in]** optional sample weights, size [n_rows] 
* **Returns:**
  n_iter: the number of solver iterations run during fitting 

### template<typename math_t>int svcFitSparse(const raft::handle_t &handle, int \*indptr, int \*indices, [math_t](#_CPPv4I0EN2ML3SVM12svcFitSparseEiRKN4raft8handle_tEPiPiP6math_tiiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t) \*data, int n_rows, int n_cols, int nnz, [math_t](#_CPPv4I0EN2ML3SVM12svcFitSparseEiRKN4raft8handle_tEPiPiP6math_tiiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t) \*labels, const [SvmParameter](#_CPPv4N2ML3SVM12SvmParameterE) &param, [ML](#_CPPv42ML)::[matrix](#_CPPv4N2ML6matrixE)::[KernelParams](#_CPPv4N2ML6matrix12KernelParamsE) &kernel_params, [SvmModel](#_CPPv4I0EN2ML3SVM8SvmModelE)<[math_t](#_CPPv4I0EN2ML3SVM12svcFitSparseEiRKN4raft8handle_tEPiPiP6math_tiiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t)> &model, const [math_t](#_CPPv4I0EN2ML3SVM12svcFitSparseEiRKN4raft8handle_tEPiPiP6math_tiiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t) \*sample_weight)

Fit a support vector classifier to the training data. 

Each row of the input data stores a feature vector. We use the SMO method to fit the [SVM](#namespaceML_1_1SVM).

The output device buffers in model shall be unallocated on entry.

* **Template Parameters:**
  **math_t** – floating point type 
* **Parameters:**
  * **handle** – **[in]** the cuML handle 
  * **indptr** – **[in]** device pointer for CSR row positions. Size [n_rows + 1]. 
  * **indices** – **[in]** device pointer for CSR column indices. Size [nnz]. 
  * **data** – **[in]** device pointer for the CSR data. Size [nnz]. 
  * **n_rows** – **[in]** number of rows 
  * **n_cols** – **[in]** number of columns 
  * **nnz** – **[in]** number of stored entries. 
  * **labels** – **[in]** device pointer for the labels. Size [n_rows]. 
  * **param** – **[in]** parameters for training 
  * **kernel_params** – **[in]** parameters for the kernel function 
  * **model** – **[out]** parameters of the trained model 
  * **sample_weight** – **[in]** optional sample weights, size [n_rows] 
* **Returns:**
  n_iter: the number of solver iterations run during fitting 

### template<typename math_t>void svcPredict(const raft::handle_t &handle, [math_t](#_CPPv4I0EN2ML3SVM10svcPredictEvRKN4raft8handle_tEP6math_tiiRN2ML6matrix12KernelParamsERK8SvmModelI6math_tEP6math_t6math_tb) \*input, int n_rows, int n_cols, [ML](#_CPPv42ML)::[matrix](#_CPPv4N2ML6matrixE)::[KernelParams](#_CPPv4N2ML6matrix12KernelParamsE) &kernel_params, const [SvmModel](#_CPPv4I0EN2ML3SVM8SvmModelE)<[math_t](#_CPPv4I0EN2ML3SVM10svcPredictEvRKN4raft8handle_tEP6math_tiiRN2ML6matrix12KernelParamsERK8SvmModelI6math_tEP6math_t6math_tb)> &model, [math_t](#_CPPv4I0EN2ML3SVM10svcPredictEvRKN4raft8handle_tEP6math_tiiRN2ML6matrix12KernelParamsERK8SvmModelI6math_tEP6math_t6math_tb) \*preds, [math_t](#_CPPv4I0EN2ML3SVM10svcPredictEvRKN4raft8handle_tEP6math_tiiRN2ML6matrix12KernelParamsERK8SvmModelI6math_tEP6math_t6math_tb) buffer_size, bool predict_class)

Predict classes or decision function value for samples in input. 

We evaluate the decision function f(x_i). Depending on the parameter predict_class, we either return f(x_i) or the label corresponding to sign(f(x_i)).

The predictions are calculated according to the following formulas:   
$$
   f(x_i) = \sum_{j=1}^n_support K(x_i, x_j) * dual_coefs[j] + b)
$$

pred(x_i) = label[sign(f(x_i))], if predict_class==true, or pred(x_i) = f(x_i), if predict_class==false.

* **Template Parameters:**
  **math_t** – floating point type 
* **Parameters:**
  * **handle** – the cuML handle 
  * **input** – **[in]** device pointer for the input data in column major format, size [n_rows x n_cols]. 
  * **n_rows** – **[in]** number of rows (input vectors) 
  * **n_cols** – **[in]** number of columns (features) 
  * **kernel_params** – **[in]** parameters for the kernel function 
  * **model** – **[in]** [SVM](#namespaceML_1_1SVM) model parameters 
  * **preds** – **[out]** device pointer to store the predicted class labels. Size [n_rows]. Should be allocated on entry. 
  * **buffer_size** – **[in]** size of temporary buffer in MiB 
  * **predict_class** – **[in]** whether to predict class label (true), or just return the decision function value (false) 

### template<typename math_t>void svcPredictSparse(const raft::handle_t &handle, int \*indptr, int \*indices, [math_t](#_CPPv4I0EN2ML3SVM16svcPredictSparseEvRKN4raft8handle_tEPiPiP6math_tiiiRN2ML6matrix12KernelParamsERK8SvmModelI6math_tEP6math_t6math_tb) \*data, int n_rows, int n_cols, int nnz, [ML](#_CPPv42ML)::[matrix](#_CPPv4N2ML6matrixE)::[KernelParams](#_CPPv4N2ML6matrix12KernelParamsE) &kernel_params, const [SvmModel](#_CPPv4I0EN2ML3SVM8SvmModelE)<[math_t](#_CPPv4I0EN2ML3SVM16svcPredictSparseEvRKN4raft8handle_tEPiPiP6math_tiiiRN2ML6matrix12KernelParamsERK8SvmModelI6math_tEP6math_t6math_tb)> &model, [math_t](#_CPPv4I0EN2ML3SVM16svcPredictSparseEvRKN4raft8handle_tEPiPiP6math_tiiiRN2ML6matrix12KernelParamsERK8SvmModelI6math_tEP6math_t6math_tb) \*preds, [math_t](#_CPPv4I0EN2ML3SVM16svcPredictSparseEvRKN4raft8handle_tEPiPiP6math_tiiiRN2ML6matrix12KernelParamsERK8SvmModelI6math_tEP6math_t6math_tb) buffer_size, bool predict_class)

Predict classes or decision function value for samples in input. 

We evaluate the decision function f(x_i). Depending on the parameter predict_class, we either return f(x_i) or the label corresponding to sign(f(x_i)).

The predictions are calculated according to the following formulas:   
$$
   f(x_i) = \sum_{j=1}^n_support K(x_i, x_j) * dual_coefs[j] + b)
$$

pred(x_i) = label[sign(f(x_i))], if predict_class==true, or pred(x_i) = f(x_i), if predict_class==falsee.

* **Template Parameters:**
  **math_t** – floating point type 
* **Parameters:**
  * **handle** – the cuML handle 
  * **indptr** – **[in]** device pointer for CSR row positions. Size [n_rows + 1]. 
  * **indices** – **[in]** device pointer for CSR column indices. Size [nnz]. 
  * **data** – **[in]** device pointer for the CSR data. Size [nnz]. 
  * **n_rows** – **[in]** number of rows 
  * **n_cols** – **[in]** number of columns 
  * **nnz** – **[in]** number of stored entries. 
  * **kernel_params** – **[in]** parameters for the kernel function 
  * **model** – **[in]** [SVM](#namespaceML_1_1SVM) model parameters 
  * **preds** – **[out]** device pointer to store the predicted class labels. Size [n_rows]. Should be allocated on entry. 
  * **buffer_size** – **[in]** size of temporary buffer in MiB 
  * **predict_class** – **[in]** whether to predict class label (true), or just return the decision function value (false) 

### template<typename math_t>void svmFreeBuffers(const raft::handle_t &handle, [SvmModel](#_CPPv4I0EN2ML3SVM8SvmModelE)<[math_t](#_CPPv4I0EN2ML3SVM14svmFreeBuffersEvRKN4raft8handle_tER8SvmModelI6math_tE)> &m)

Deallocate device buffers in the [SvmModel](#structML_1_1SVM_1_1SvmModel) struct.

* **Parameters:**
  * **handle** – **[in]** cuML handle 
  * **m** – **[inout]** [SVM](#namespaceML_1_1SVM) model parameters 

### template<typename math_t>int svrFit(const raft::handle_t &handle, [math_t](#_CPPv4I0EN2ML3SVM6svrFitEiRKN4raft8handle_tEP6math_tiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t) \*X, int n_rows, int n_cols, [math_t](#_CPPv4I0EN2ML3SVM6svrFitEiRKN4raft8handle_tEP6math_tiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t) \*y, const [SvmParameter](#_CPPv4N2ML3SVM12SvmParameterE) &param, [ML](#_CPPv42ML)::[matrix](#_CPPv4N2ML6matrixE)::[KernelParams](#_CPPv4N2ML6matrix12KernelParamsE) &kernel_params, [SvmModel](#_CPPv4I0EN2ML3SVM8SvmModelE)<[math_t](#_CPPv4I0EN2ML3SVM6svrFitEiRKN4raft8handle_tEP6math_tiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t)> &model, const [math_t](#_CPPv4I0EN2ML3SVM6svrFitEiRKN4raft8handle_tEP6math_tiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t) \*sample_weight)

Fit a support vector regressor to the training data. 

Each row of the input data stores a feature vector.

The output buffers in model shall be unallocated on entry.

* **Template Parameters:**
  **math_t** – floating point type 
* **Parameters:**
  * **handle** – **[in]** the cuML handle 
  * **X** – **[in]** device pointer for the input data in column major format. Size n_rows x n_cols. 
  * **n_rows** – **[in]** number of rows 
  * **n_cols** – **[in]** number of columns 
  * **y** – **[in]** device pointer for target values. Size [n_rows]. 
  * **param** – **[in]** parameters for training 
  * **kernel_params** – **[in]** parameters for the kernel function 
  * **model** – **[out]** parameters of the trained model 
  * **sample_weight** – **[in]** optional sample weights, size [n_rows] 
* **Returns:**
  n_iter: the number of solver iterations run during fitting 

### template<typename math_t>int svrFitSparse(const raft::handle_t &handle, int \*indptr, int \*indices, [math_t](#_CPPv4I0EN2ML3SVM12svrFitSparseEiRKN4raft8handle_tEPiPiP6math_tiiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t) \*data, int n_rows, int n_cols, int nnz, [math_t](#_CPPv4I0EN2ML3SVM12svrFitSparseEiRKN4raft8handle_tEPiPiP6math_tiiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t) \*y, const [SvmParameter](#_CPPv4N2ML3SVM12SvmParameterE) &param, [ML](#_CPPv42ML)::[matrix](#_CPPv4N2ML6matrixE)::[KernelParams](#_CPPv4N2ML6matrix12KernelParamsE) &kernel_params, [SvmModel](#_CPPv4I0EN2ML3SVM8SvmModelE)<[math_t](#_CPPv4I0EN2ML3SVM12svrFitSparseEiRKN4raft8handle_tEPiPiP6math_tiiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t)> &model, const [math_t](#_CPPv4I0EN2ML3SVM12svrFitSparseEiRKN4raft8handle_tEPiPiP6math_tiiiP6math_tRK12SvmParameterRN2ML6matrix12KernelParamsER8SvmModelI6math_tEPK6math_t) \*sample_weight)

Fit a support vector regressor to the training data. 

Each row of the input data stores a feature vector.

The output buffers in model shall be unallocated on entry.

* **Template Parameters:**
  **math_t** – floating point type 
* **Parameters:**
  * **handle** – **[in]** the cuML handle 
  * **indptr** – **[in]** device pointer for CSR row positions. Size [n_rows + 1]. 
  * **indices** – **[in]** device pointer for CSR column indices. Size [nnz]. 
  * **data** – **[in]** device pointer for the CSR data. Size [nnz]. 
  * **n_rows** – **[in]** number of rows 
  * **n_cols** – **[in]** number of columns 
  * **nnz** – **[in]** number of stored entries. 
  * **y** – **[in]** device pointer for target values. Size [n_rows]. 
  * **param** – **[in]** parameters for training 
  * **kernel_params** – **[in]** parameters for the kernel function 
  * **model** – **[out]** parameters of the trained model 
  * **sample_weight** – **[in]** optional sample weights, size [n_rows] 
* **Returns:**
  n_iter: the number of solver iterations run during fitting 

### template<typename math_t>class SmoSolver

 *#include <smosolver.h>*

Solve the quadratic optimization problem using two level decomposition and Sequential Minimal Optimization (SMO). 

The general decomposition idea by Osuna is to choose q examples from all the training examples, and solve the QP problem for this subset (discussed in section 11.2 by Joachims [1]). SMO is the extreme case where we choose q=2.

Here we follow [2] and [3] and use two level decomposition. First we set q_1=1024, and solve the QP sub-problem for that (let’s call it QP1). This is the outer iteration, implemented in [SmoSolver::Solve](#classML_1_1SVM_1_1SmoSolver_1a7961fc90b0ed16fd7f7e9fb718b60bf4).

To solve QP1, we use another decomposition, specifically the SMO (q_2 = 2), which is implemented in SmoBlockSolve.

References:
* [1] Joachims, T. Making large-scale support vector machine learning practical. In B. Scholkopf, C. Burges, & A. Smola (Eds.), Advances in kernel methods: Support vector machines. Cambridge, MA: MIT Press (1998)
* [2] J. Vanek et al. A GPU-Architecture Optimized Hierarchical Decomposition Algorithm for Support VectorMachine Training, IEEE Transactions on Parallel and Distributed Systems, vol 28, no 12, 3330, (2017)
* [3] Z. Wen et al. ThunderSVM: A Fast [SVM](#namespaceML_1_1SVM) Library on GPUs and CPUs, Journal of Machine Learning Research, 19, 1-5 (2018) 

### Public Functions

### template<typename MatrixViewType>void Solve([MatrixViewType](#_CPPv4I0EN2ML3SVM9SmoSolver5SolveEv14MatrixViewTypeiiP6math_tPK6math_tPP6math_tPiP14SupportStorageI6math_tEPPiP6math_tiii) matrix, int n_rows, int n_cols, [math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE) \*y, const [math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE) \*sample_weight, [math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE) \*\*dual_coefs, int \*n_support, [SupportStorage](#_CPPv4I0EN2ML3SVM14SupportStorageE)<[math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE)> \*support_matrix, int \*\*idx, [math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE) \*b, int max_iter = -1, int max_outer_iter = -1, int max_inner_iter = 10000)

Solve the quadratic optimization problem. 

The output arrays (dual_coefs, support_matrix, idx) will be allocated on the device, they should be unallocated on entry.

* **Parameters:**
  * **matrix** – **[in]** training vectors in matrix format(MLCommon::Matrix::Matrix), size [n_rows x \* n_cols] 
  * **n_rows** – **[in]** number of rows (training vectors) 
  * **n_cols** – **[in]** number of columns (features) 
  * **y** – **[in]** labels (values +/-1), size [n_rows] 
  * **sample_weight** – **[in]** device array of sample weights (or nullptr if not applicable) 
  * **dual_coefs** – **[out]** size [n_support] on exit 
  * **n_support** – **[out]** number of support vectors 
  * **support_matrix** – **[out]** support vectors in matrix format, size [n_support, n_cols] 
  * **idx** – **[out]** the original training set indices of the support vectors, size [n_support] 
  * **b** – **[out]** scalar constant for the decision function 
  * **max_iter** – **[in]** maximum number of total iterations (default -1 for no limit) 
  * **max_outer_iter** – **[in]** maximum number of outer iteration (default 100 \* n_rows) 
  * **max_inner_iter** – **[in]** maximum number of inner iterations (default 10000) 

### void UpdateF([math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE) \*f, int n_rows, const [math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE) \*delta_alpha, int n_ws, const [math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE) \*cacheTile)

Update the f vector after a block solve step. 

$$
 f_i = f_i + \sum_{k\in WS} K_{i,k} * \Delta \alpha_k, 
$$

 where i = [0..n_train-1], WS is the set of workspace indices, and $K_{i,k}$ is the kernel function evaluated for training vector x_i and workspace vector x_k.

* **Parameters:**
  * **f** – size [n_train] 
  * **n_rows** – 
  * **delta_alpha** – size [n_ws] 
  * **n_ws** – 
  * **cacheTile** – kernel function evaluated for the following set K[X,x_ws], size [n_rows, n_ws] 

### void Initialize([math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE) \*\*y, const [math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE) \*sample_weight, int n_rows, int n_cols)

Initialize the problem to solve. 

Both [SVC](#classML_1_1SVM_1_1SVC) and SVR are solved as a classification problem. The optimization target (W) does not appear directly in the SMO formulation, only its derivative through f (optimality indicator vector): 
$$
 f_i = y_i \frac{\partial W }{\partial \alpha_i}. 
$$

The f_i values are initialized here, and updated at every solver iteration when alpha changes. The update step is the same for [SVC](#classML_1_1SVM_1_1SVC) and SVR, only the init step differs.

Additionally, we zero init the dual coefficients (alpha), and initialize class labels for SVR.

* **Parameters:**
  * **y** – **[inout]** on entry class labels or target values, on exit device pointer to class labels 
  * **sample_weight** – **[in]** sample weights (can be nullptr, otherwise device array of size [n_rows]) 
  * **n_rows** – **[in]** 
  * **n_cols** – **[in]** 

### void SvcInit(const [math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE) \*y)

Initialize Support Vector Classification. 

We would like to maximize the following quantity  
$$
 W(\mathbf{\alpha}) = -\mathbf{\alpha}^T \mathbf{1}
  + \frac{1}{2} \mathbf{\alpha}^T Q \mathbf{\alpha}, 
$$

We initialize f as:  
$$
 f_i = y_i \frac{\partial W(\mathbf{\alpha})}{\partial \alpha_i} =
         -y_i +   y_j \alpha_j K(\mathbf{x}_i, \mathbf{x}_j) 
$$

* **Parameters:**
  **y** – **[in]** device pointer of class labels size [n_rows] 

### void SvrInit(const [math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE) \*yr, int n_rows, [math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE) \*yc, [math_t](#_CPPv4I0EN2ML3SVM9SmoSolverE) \*f)

Initializes the solver for epsilon-SVR. 

For regression we are optimizing the following quantity       
$$
W(\alpha^+, \alpha^-) =
\epsilon \sum_{i=1}^l (\alpha_i^+ + \alpha_i^-)
- \sum_{i=1}^l yc_i (\alpha_i^+ - \alpha_i^-)
+ \frac{1}{2} \sum_{i,j=1}^l
  (\alpha_i^+ - \alpha_i^-)(\alpha_j^+ - \alpha_j^-) K(\bm{x}_i, \bm{x}_j)
$$

Then $ f_i = y_i \frac{\partial W(\alpha}{\partial \alpha_i} $ $     = yc_i*epsilon - yr_i $

Additionally we set class labels for the training vectors.

References: [1] B. Schölkopf et. al (1998): New support vector algorithms, NeuroCOLT2 Technical Report Series, NC2-TR-1998-031, Section 6 [2] A.J. Smola, B. Schölkopf (2004): A tutorial on support vector regression, Statistics and Computing 14, 199–222 [3] Orchel M. (2011) Support Vector Regression as a Classification Problem with a Priori Knowledge in the Form of Detractors, Man-Machine Interactions 2. Advances in Intelligent and Soft Computing, vol 103

* **Parameters:**
  * **yr** – **[in]** device pointer with values for regression, size [n_rows] 
  * **n_rows** – **[in]** 
  * **yc** – **[out]** device pointer to classes associated to the dual coefficients, size [n_rows\*2] 
  * **f** – **[out]** device pointer f size [n_rows\*2] 

### template<typename math_t>struct SupportStorage

 *#include <svm_model.h>*

### template<typename math_t>class SVC

 *#include <svc.hpp>*

C-Support Vector Classification. 

This is a Scikit-Learn like wrapper around the stateless C++ functions. See Issue #456 for general discussion about stateful Sklearn like wrappers.

The classifier will be fitted using the SMO algorithm in dual space.

The decision function takes the following form   
$$
   sign\left( \sum_{i=1}^{N_{support}} y_i \alpha_i K(x_i,x) + b \right),
$$

 where $x_i$ are the support vectors, and $ y_i \alpha_i $ are the dual coordinates.

The penalty parameter C limits the values of the dual coefficients 
$$
 0 <= \alpha <= C 
$$

### Public Functions

### SVC(raft::handle_t &handle, [math_t](#_CPPv4I0EN2ML3SVM3SVCE) C = 1, [math_t](#_CPPv4I0EN2ML3SVM3SVCE) tol = 1.0e-3, [ML](#_CPPv42ML)::[matrix](#_CPPv4N2ML6matrixE)::[KernelParams](#_CPPv4N2ML6matrix12KernelParamsE) kernel_params = [ML](#_CPPv42ML)::[matrix](#_CPPv4N2ML6matrixE)::[KernelParams](#_CPPv4N2ML6matrix12KernelParamsE){[ML](#_CPPv42ML)::[matrix](#_CPPv4N2ML6matrixE)::[KernelType](#_CPPv4N2ML6matrix10KernelTypeE)::[LINEAR](#_CPPv4N2ML6matrix10KernelType6LINEARE), 3, 1, 0}, [math_t](#_CPPv4I0EN2ML3SVM3SVCE) cache_size = 200, int max_iter = -1, int nochange_steps = 1000, rapids_logger::level_enum verbosity = rapids_logger::level_enum::info)

Constructs a support vector classifier. 

* **Parameters:**
  * **handle** – cuML handle 
  * **C** – penalty term 
  * **tol** – tolerance to stop fitting 
  * **kernel_params** – parameters for kernels 
  * **cache_size** – size of kernel cache in device memory (MiB) 
  * **max_iter** – maximum number of outer iterations in [SmoSolver](#classML_1_1SVM_1_1SmoSolver)
  * **nochange_steps** – number of steps with no change wrt convergence 
  * **verbosity** – verbosity level for logging messages during execution 

### void fit([math_t](#_CPPv4I0EN2ML3SVM3SVCE) \*input, int n_rows, int n_cols, [math_t](#_CPPv4I0EN2ML3SVM3SVCE) \*labels, const [math_t](#_CPPv4I0EN2ML3SVM3SVCE) \*sample_weight = nullptr)

Fit a support vector classifier to the training data. 

Each row of the input data stores a feature vector. We use the SMO method to fit the [SVM](#namespaceML_1_1SVM).

* **Parameters:**
  * **input** – device pointer for the input data in column major format. Size n_rows x n_cols. 
  * **n_rows** – number of rows 
  * **n_cols** – number of columns 
  * **labels** – device pointer for the labels. Size n_rows. 
  * **sample_weight** – **[in]** optional sample weights, size [n_rows] 

### void predict([math_t](#_CPPv4I0EN2ML3SVM3SVCE) \*input, int n_rows, int n_cols, [math_t](#_CPPv4I0EN2ML3SVM3SVCE) \*preds)

Predict classes for samples in input. 

* **Parameters:**
  * **input** – **[in]** device pointer for the input data in column major format, size [n_rows x n_cols]. 
  * **n_rows** – **[in]** number of vectors 
  * **n_cols** – **[in]** number of features 
  * **preds** – **[out]** device pointer to store the predicted class labels. Size [n_rows]. Should be allocated on entry. 

### void decisionFunction([math_t](#_CPPv4I0EN2ML3SVM3SVCE) \*input, int n_rows, int n_cols, [math_t](#_CPPv4I0EN2ML3SVM3SVCE) \*preds)

Calculate decision function value for samples in input. 

* **Parameters:**
  * **input** – **[in]** device pointer for the input data in column major format, size [n_rows x n_cols]. 
  * **n_rows** – **[in]** number of vectors 
  * **n_cols** – **[in]** number of features 
  * **preds** – **[out]** device pointer to store the decision function value Size [n_rows]. Should be allocated on entry. 

### template<typename math_t>struct SvmModel

 *#include <svm_model.h>*

Parameters that describe a trained [SVM](#namespaceML_1_1SVM) model. All pointers are device pointers. 

### Public Members

### int n_support

Number of support vectors. 

### int n_cols

Number of features. 

### [math_t](#_CPPv4I0EN2ML3SVM8SvmModelE) b

Constant used in the decision function. 

### [math_t](#_CPPv4I0EN2ML3SVM8SvmModelE) \*dual_coefs

Non-zero dual coefficients ( dual_coef[i] = $ y_i \alpha_i $). Size [n_support]. 

### [SupportStorage](#_CPPv4I0EN2ML3SVM14SupportStorageE)<[math_t](#_CPPv4I0EN2ML3SVM8SvmModelE)> support_matrix

Support vector storage - can contain either CSR or dense. 

### int \*support_idx

Indices (from the training set) of the support vectors, size [n_support]. 

### int n_classes

Number of classes found in the input labels 

### [math_t](#_CPPv4I0EN2ML3SVM8SvmModelE) \*unique_labels

Device pointer for the unique classes. Size [n_classes]. 

### struct SvmParameter

 *#include <svm_parameter.h>*

Numerical input parameters for an [SVM](#namespaceML_1_1SVM).

There are several parameters that control how long we train. The training stops if:
* max_outer_iter outer iterations are reached. If you pass -1, then max_diff = 100 \* n_rows
* max_iter total iterations are reached. Pass -1 for no limit on total iterations.
* the diff becomes less the tol
* the diff is changing less then 0.001\*tol in nochange_steps consecutive outer iterations. 

### Public Members

### double C

Penalty term C. 

### double cache_size

kernel cache size in MiB 

### double tol

Tolerance used to stop fitting. 

### rapids_logger::level_enum verbosity

Print information about training. 

### double epsilon

epsilon parameter for epsilon-SVR 

### template<typename math_t>class WorkingSet

 *#include <workingset.h>*

Working set selection for the SMO algorithm.

The working set is a subset of the training vectors, by default it has 1024 elements. At every outer iteration in [SmoSolver::Solve](#classML_1_1SVM_1_1SmoSolver_1a7961fc90b0ed16fd7f7e9fb718b60bf4), we select a different working set, and optimize the dual coefficients for the working set.

The vectors are selected based on the f values, which is the difference between the target label and the decision function value. 

### Public Functions

### inline WorkingSet(const raft::handle_t &handle, cudaStream_t stream, int n_rows = 0, int n_ws = 0, [SvmType](#_CPPv4N2ML3SVM7SvmTypeE) svmType = C_SVC)

Manage a working set. 

* **Parameters:**
  * **handle** – cuml handle implementation 
  * **stream** – cuda stream for working set operations 
  * **n_rows** – number of training vectors 
  * **n_ws** – number of elements in the working set (default 1024) 
  * **svmType** – classification or regression 

### inline void SetSize(int n_train, int n_ws = 0)

Set the size of the working set and allocate buffers accordingly. 

* **Parameters:**
  * **n_train** – number of training vectors 
  * **n_ws** – working set size (default min(1024, n_train)) 

### inline int GetSize()

Return the size of the working set. 

### inline int \*GetIndices()

Return a device pointer to the the working set indices. 

The returned array is owned by [WorkingSet](#classML_1_1SVM_1_1WorkingSet). 

### void SimpleSelect([math_t](#_CPPv4I0EN2ML3SVM10WorkingSetE) \*f, [math_t](#_CPPv4I0EN2ML3SVM10WorkingSetE) \*alpha, [math_t](#_CPPv4I0EN2ML3SVM10WorkingSetE) \*y, const [math_t](#_CPPv4I0EN2ML3SVM10WorkingSetE) \*C, int n_already_selected = 0)

Select new elements for a working set. 

Here we follow the working set selection strategy by Joachims [1], we select n training instances as:
* select n/2 element of upper set, where f is largest
* select n/2 from lower set, where f is smallest

The difference compared to Joachims’ strategy is that we can already have some elements selected by a different strategy, therefore we select only n = n_ws - n_already_selected.

References: [1] Joachims, T. (1998). Making large-scale support vector machine learning practical. In B. Scholkopf, C. Burges, & A. Smola (Eds.), Advances in kernel methods: Support vector machines. Cambridge, MA: MIT Press

* **Parameters:**
  * **f** – optimality indicator vector, size [n_train] 
  * **alpha** – dual coefficients, size [n_train] 
  * **y** – target labels (+/- 1) 
  * **C** – penalty parameter vector size [n_train] 
  * **n_already_selected** – 

### inline void Select([math_t](#_CPPv4I0EN2ML3SVM10WorkingSetE) \*f, [math_t](#_CPPv4I0EN2ML3SVM10WorkingSetE) \*alpha, [math_t](#_CPPv4I0EN2ML3SVM10WorkingSetE) \*y, const [math_t](#_CPPv4I0EN2ML3SVM10WorkingSetE) \*C)

Select working set indices. 

To avoid training vectors oscillating in and out of the working set, we keep half of the previous working set, and fill new elements only to the other half.

We can have a FIFO retention policy, or we can consider the time (=ws_priority) a vector already spent in the ws. References: [1] Z. Wen et al. ThunderSVM: A Fast [SVM](#namespaceML_1_1SVM) Library on GPUs and CPUs, Journal of Machine Learning Research, 19, 1-5 (2018)

* **Parameters:**
  * **f** – optimality indicator vector, size [n_train] 
  * **alpha** – dual coefficients, size [n_train] 
  * **y** – class labels, size [n_train] 
  * **C** – penalty parameter vector, size [n_train] 

### int PrioritySelect([math_t](#_CPPv4I0EN2ML3SVM10WorkingSetE) \*alpha, const [math_t](#_CPPv4I0EN2ML3SVM10WorkingSetE) \*C, int nc)

Select elements from the previous working set based on their priority. 

We sort the old working set based on their priority in ascending order, and then select nc elements from free, and then lower/upper bound vectors. For details see [2].

See Issue #946.

References: [2] T Serafini, L Zanni: On the Working Set selection in grad. projection based decomposition techniques for Support Vector Machines DOI: 10.1080/10556780500140714

* **Parameters:**
  * **alpha** – **[in]** device vector of dual coefficients, size [n_train] 
  * **C** – **[in]** penalty parameter 
  * **nc** – **[in]** number of elements to select 

### Public Members

### bool FIFO_strategy = true

> Workspace selection strategy, note that only FIFO is tested so far 

### namespace linear

### Functions

### template<typename T>int fit(const raft::handle_t &handle, const [Params](#_CPPv4N2ML3SVM6linear6ParamsE) &params, const std::size_t nRows, const std::size_t nCols, const int nClasses, const [T](#_CPPv4I0EN2ML3SVM6linear3fitEiRKN4raft8handle_tERK6ParamsKNSt6size_tEKNSt6size_tEKiPK1TPK1TPK1TPK1TP1T) \*classes, const [T](#_CPPv4I0EN2ML3SVM6linear3fitEiRKN4raft8handle_tERK6ParamsKNSt6size_tEKNSt6size_tEKiPK1TPK1TPK1TPK1TP1T) \*X, const [T](#_CPPv4I0EN2ML3SVM6linear3fitEiRKN4raft8handle_tERK6ParamsKNSt6size_tEKNSt6size_tEKiPK1TPK1TPK1TPK1TP1T) \*y, const [T](#_CPPv4I0EN2ML3SVM6linear3fitEiRKN4raft8handle_tERK6ParamsKNSt6size_tEKNSt6size_tEKiPK1TPK1TPK1TPK1TP1T) \*sampleWeight, [T](#_CPPv4I0EN2ML3SVM6linear3fitEiRKN4raft8handle_tERK6ParamsKNSt6size_tEKNSt6size_tEKiPK1TPK1TPK1TPK1TP1T) \*w)

Fit a linear [SVM](#namespaceML_1_1SVM) model. 

* **Parameters:**
  * **handle** – **[in]** the cuML handle. 
  * **params** – **[in]** the model parameters. 
  * **nRows** – **[in]** the number of input samples. 
  * **nCols** – **[in]** the number of feature dimensions. 
  * **nClasses** – **[in]** the number of input classes, or 0 for a regression problem. 
  * **classes** – **[in]** the unique input classes, shape=(nClasses,), or nullptr for a regression problem. 
  * **X** – **[in]** the training data, shape=(nRows, nCols), F-contiguous 
  * **y** – **[in]** the target data, shape=(nRows,) 
  * **sampleWeight** – **[in]** non-negative weights for the training data, shape=(nRows,), or nullptr if unweighted. 
  * **w** – **[out]** the fitted weights, shape=(nCoefs, nCols) or (nCoefs + 1, nCols + 1) if `fit_intercept=true`, where nCoefs = 1 for regression or if nClasses = 2, and nClasses otherwise. F-contiguous. 
* **Returns:**
  n_iter: the maximum number of iterations run across all classes. 

### struct Params

 *#include <linear.hpp>*

### Public Types

### enum Penalty

The regularization term. 

*Values:*

### enumerator L1

Abs. value of the weights: `sum |w|`

### enumerator L2

Squared value of the weights: `sum w^2`

### enum Loss

The loss function. 

*Values:*

### enumerator HINGE

`max(1 - y_i x_i w, 0)`

### enumerator SQUARED_HINGE

`max(1 - y_i x_i w, 0)^2`

### enumerator EPSILON_INSENSITIVE

`max(|y_i - x_i w| - [epsilon](#structML_1_1SVM_1_1linear_1_1Params_1ac7a0fe4009dfc4daa871df86b8e3e87c), 0)`

### enumerator SQUARED_EPSILON_INSENSITIVE

`max(|y_i - x_i w| - [epsilon](#structML_1_1SVM_1_1linear_1_1Params_1ac7a0fe4009dfc4daa871df86b8e3e87c), 0)^2`

### Public Members

### [Penalty](#_CPPv4N2ML3SVM6linear6Params7PenaltyE) penalty = L2

The regularization term. 

### [Loss](#_CPPv4N2ML3SVM6linear6Params4LossE) loss = HINGE

The loss function. 

### bool fit_intercept = true

Whether to fit the bias term. 

### bool penalized_intercept = false

When true, the bias term is treated the same way as other data features. Enabling this feature forces an extra copying the input data X. 

### int max_iter = 1000

Maximum number of iterations for the underlying QN solver. 

### int linesearch_max_iter = 100

Maximum number of linesearch (inner loop) iterations for the underlying QN solver. 

### int lbfgs_memory = 5

Number of vectors approximating the hessian for the underlying QN solver (l-bfgs). 

### rapids_logger::level_enum verbose = rapids_logger::level_enum::off

Triggers extra output when greater than zero. 

### double C = 1.0

The constant scaling factor of the main term in the loss function. (You can also think of that as the inverse factor of the penalty term). 

### double grad_tol = 0.0001

The threshold on the gradient for the underlying QN solver. 

### double change_tol = 0.00001

The threshold on the function change for the underlying QN solver. 

### double epsilon = 0.0

The epsilon-sensitivity parameter (applicable to the SVM-regression (SVR) loss functions). 

### namespace TSVD

### namespace opg

### Functions

### void fit(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, std::uint32_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[floatData_t](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix11floatData_tE) \*\*input, float \*components, float \*singular_vals, [paramsTSVDMG](#_CPPv4N2ML12paramsTSVDMGE) &prms, bool verbose = false)

performs MNMG fit operation for the tsvd 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **rank_sizes** – **[in]** includes all the partition size information for the rank 
  * **n_parts** – **[in]** number of partitions 
  * **input** – **[in]** input data 
  * **components** – **[out]** principal components of the input data 
  * **singular_vals** – **[out]** singular values of the data 
  * **prms** – **[in]** data structure that includes all the parameters from input size to algorithm 
  * **verbose** – **[in]** 

### void fit(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, std::uint32_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[doubleData_t](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12doubleData_tE) \*\*input, double \*components, double \*singular_vals, [paramsTSVDMG](#_CPPv4N2ML12paramsTSVDMGE) &prms, bool verbose = false)

### void fit_transform(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float>\*> &trans_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &trans_desc, float \*components, float \*explained_var, float \*explained_var_ratio, float \*singular_vals, [paramsTSVDMG](#_CPPv4N2ML12paramsTSVDMGE) &prms, bool verbose)

performs MNMG fit and transform operation for the tsvd. 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **input_data** – **[in]** input data 
  * **input_desc** – **[in]** input descriptor for data 
  * **trans_data** – **[out]** transformed input data 
  * **trans_desc** – **[out]** transformed input data descriptor 
  * **components** – **[out]** principal components of the input data 
  * **explained_var** – **[out]** explained var 
  * **explained_var_ratio** – **[out]** the explained var ratio 
  * **singular_vals** – **[out]** singular values of the data 
  * **prms** – **[in]** data structure that includes all the parameters from input size to algorithm 
  * **verbose** – **[in]** 

### void fit_transform(raft::handle_t &handle, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double>\*> &input_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &input_desc, std::vector<[MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double>\*> &trans_data, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[PartDescriptor](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix14PartDescriptorE) &trans_desc, double \*components, double \*explained_var, double \*explained_var_ratio, double \*singular_vals, [paramsTSVDMG](#_CPPv4N2ML12paramsTSVDMGE) &prms, bool verbose)

### void transform(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, std::uint32_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*input, float \*components, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*trans_input, [paramsTSVDMG](#_CPPv4N2ML12paramsTSVDMGE) &prms, bool verbose)

performs MNMG transform operation for the tsvd. 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **rank_sizes** – **[in]** includes all the partition size information for the rank 
  * **n_parts** – **[in]** number of partitions 
  * **input** – **[in]** input data 
  * **components** – **[in]** principal components of the input data 
  * **trans_input** – **[out]** transformed input data 
  * **prms** – **[in]** data structure that includes all the parameters from input size to algorithm 
  * **verbose** – **[in]** 

### void transform(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, std::uint32_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*input, double \*components, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*trans_input, [paramsTSVDMG](#_CPPv4N2ML12paramsTSVDMGE) &prms, bool verbose)

### void inverse_transform(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, std::uint32_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*trans_input, float \*components, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<float> \*\*input, [paramsTSVDMG](#_CPPv4N2ML12paramsTSVDMGE) &prms, bool verbose)

performs MNMG inverse transform operation for the output. 

* **Parameters:**
  * **handle** – **[in]** the internal cuml handle object 
  * **rank_sizes** – **[in]** includes all the partition size information for the rank 
  * **n_parts** – **[in]** number of partitions 
  * **trans_input** – **[in]** transformed input data 
  * **components** – **[in]** principal components of the input data 
  * **input** – **[out]** input data 
  * **prms** – **[in]** data structure that includes all the parameters from input size to algorithm 
  * **verbose** – **[in]** 

### void inverse_transform(raft::handle_t &handle, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[RankSizePair](../mlcommon/index.html.md#_CPPv4N8MLCommon6Matrix12RankSizePairE) \*\*rank_sizes, std::uint32_t n_parts, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*trans_input, double \*components, [MLCommon](../mlcommon/index.html.md#_CPPv48MLCommon)::[Matrix](../mlcommon/index.html.md#_CPPv4N8MLCommon6MatrixE)::[Data](../mlcommon/index.html.md#_CPPv4I0EN8MLCommon6Matrix4DataE)<double> \*\*input, [paramsTSVDMG](#_CPPv4N2ML12paramsTSVDMGE) &prms, bool verbose)

### namespace UMAP

### Functions

### void find_ab(const raft::handle_t &handle, [UMAPParams](#_CPPv4N2ML10UMAPParamsE) \*params)

Returns the simplical set to be consumed by the [ML::UMAP::refine](#namespaceML_1_1UMAP_1a2bdcc85561a9ae6d3b87d5baa4fb980b) function.

* **Parameters:**
  * **handle** – **[in]** raft::handle_t 
  * **params** – **[out]** pointer to [ML::UMAPParams](#classML_1_1UMAPParams) object of which the a and b parameters will be updated 

### std::unique_ptr<raft::sparse::COO<float, int>> get_graph(const raft::handle_t &handle, float \*X, float \*y, int n, int d, int64_t \*knn_indices, float \*knn_dists, [UMAPParams](#_CPPv4N2ML10UMAPParamsE) \*params)

Returns the simplical set to be consumed by the [ML::UMAP::refine](#namespaceML_1_1UMAP_1a2bdcc85561a9ae6d3b87d5baa4fb980b) function.

* **Parameters:**
  * **handle** – **[in]** raft::handle_t 
  * **X** – **[in]** pointer to input array 
  * **y** – **[in]** pointer to labels array 
  * **n** – **[in]** n_samples of input array 
  * **d** – **[in]** n_features of input array 
  * **knn_indices** – **[in]** pointer to knn_indices (optional) 
  * **knn_dists** – **[in]** pointer to knn_dists (optional) 
  * **params** – **[in]** pointer to [ML::UMAPParams](#classML_1_1UMAPParams) object 
* **Returns:**
  : simplical set as a unique pointer to a raft::sparse::COO object 

### void refine(const raft::handle_t &handle, float \*X, int n, int d, raft::sparse::COO<float, int> \*graph, [UMAPParams](#_CPPv4N2ML10UMAPParamsE) \*params, float \*embeddings)

Performs a [UMAP](#namespaceML_1_1UMAP) fit on existing embeddings without reinitializing them, which enables iterative fitting without callbacks.

* **Parameters:**
  * **handle** – **[in]** raft::handle_t 
  * **X** – **[in]** pointer to input array 
  * **n** – **[in]** n_samples of input array 
  * **d** – **[in]** n_features of input array 
  * **graph** – **[in]** pointer to raft::sparse::COO object computed using [ML::UMAP::get_graph](#namespaceML_1_1UMAP_1aa6fcdf1c4da10e11029c2e886a3a6db4)
  * **params** – **[in]** pointer to [ML::UMAPParams](#classML_1_1UMAPParams) object 
  * **embeddings** – **[out]** pointer to current embedding with shape n \* n_components, stores updated embeddings on executing refine 

### void init_and_refine(const raft::handle_t &handle, float \*X, int n, int d, raft::sparse::COO<float, int> \*graph, [UMAPParams](#_CPPv4N2ML10UMAPParamsE) \*params, float \*embeddings)

Initializes embeddings and performs a [UMAP](#namespaceML_1_1UMAP) fit on them, which enables iterative fitting without callbacks.

* **Parameters:**
  * **handle** – **[in]** raft::handle_t 
  * **X** – **[in]** pointer to input array 
  * **n** – **[in]** n_samples of input array 
  * **d** – **[in]** n_features of input array 
  * **graph** – **[in]** pointer to raft::sparse::COO object computed using [ML::UMAP::get_graph](#namespaceML_1_1UMAP_1aa6fcdf1c4da10e11029c2e886a3a6db4)
  * **params** – **[in]** pointer to [ML::UMAPParams](#classML_1_1UMAPParams) object 
  * **embeddings** – **[out]** pointer to current embedding with shape n \* n_components, stores updated embeddings on executing refine 

### void fit(const raft::handle_t &handle, float \*X, float \*y, int n, int d, int64_t \*knn_indices, float \*knn_dists, [UMAPParams](#_CPPv4N2ML10UMAPParamsE) \*params, std::unique_ptr<[rmm](https://docs.nvidia.com/rmm/latest/cpp/rmm_namespace/#_CPPv43rmm)::[device_buffer](https://docs.nvidia.com/rmm/latest/cpp/data_containers/#_CPPv4N3rmm13device_bufferE)> &embeddings, raft::host_coo_matrix<float, int, int, uint64_t> &graph, float \*sigmas = nullptr, float \*rhos = nullptr)

Dense fit

* **Parameters:**
  * **handle** – **[in]** raft::handle_t 
  * **X** – **[in]** pointer to input array 
  * **y** – **[in]** pointer to labels array 
  * **n** – **[in]** n_samples of input array 
  * **d** – **[in]** n_features of input array 
  * **knn_indices** – **[in]** pointer to knn_indices of input (optional) 
  * **knn_dists** – **[in]** pointer to knn_dists of input (optional) 
  * **params** – **[in]** pointer to [ML::UMAPParams](#classML_1_1UMAPParams) object 
  * **embeddings** – **[out]** unique_ptr to device_buffer that will be allocated and filled with embeddings 
  * **graph** – **[out]** pointer to fuzzy simplicial set graph 
  * **sigmas** – **[out]** optional output array for per-point sigma values (size n, device memory) 
  * **rhos** – **[out]** optional output array for per-point rho values (size n, device memory) 

### void fit_sparse(const raft::handle_t &handle, int \*indptr, int \*indices, float \*data, size_t nnz, float \*y, int n, int d, int \*knn_indices, float \*knn_dists, [UMAPParams](#_CPPv4N2ML10UMAPParamsE) \*params, std::unique_ptr<[rmm](https://docs.nvidia.com/rmm/latest/cpp/rmm_namespace/#_CPPv43rmm)::[device_buffer](https://docs.nvidia.com/rmm/latest/cpp/data_containers/#_CPPv4N3rmm13device_bufferE)> &embeddings, raft::host_coo_matrix<float, int, int, uint64_t> &graph)

[Sparse](#namespaceML_1_1Sparse) fit

* **Parameters:**
  * **handle** – **[in]** raft::handle_t 
  * **indptr** – **[in]** pointer to index pointer array of input array 
  * **indices** – **[in]** pointer to index array of input array 
  * **data** – **[in]** pointer to data array of input array 
  * **nnz** – **[in]** pointer to data array of input array 
  * **y** – **[in]** pointer to labels array 
  * **n** – **[in]** n_samples of input array 
  * **d** – **[in]** n_features of input array 
  * **knn_indices** – **[in]** pointer to knn_indices of input (optional) 
  * **knn_dists** – **[in]** pointer to knn_dists of input (optional) 
  * **params** – **[in]** pointer to [ML::UMAPParams](#classML_1_1UMAPParams) object 
  * **embeddings** – **[out]** unique_ptr to device_buffer that will be allocated and filled with embeddings 
  * **graph** – **[out]** pointer to fuzzy simplicial set graph 

### void transform(const raft::handle_t &handle, float \*X, int n, int d, float \*orig_X, int orig_n, float \*embedding, int embedding_n, [UMAPParams](#_CPPv4N2ML10UMAPParamsE) \*params, float \*transformed)

Dense transform

* **Parameters:**
  * **handle** – **[in]** raft::handle_t 
  * **X** – **[in]** pointer to input array to be inferred 
  * **n** – **[in]** n_samples of input array to be inferred 
  * **d** – **[in]** n_features of input array to be inferred 
  * **orig_X** – **[in]** pointer to original training array 
  * **orig_n** – **[in]** number of rows in original training array 
  * **embedding** – **[in]** pointer to embedding created during training 
  * **embedding_n** – **[in]** number of rows in embedding created during training 
  * **params** – **[in]** pointer to [ML::UMAPParams](#classML_1_1UMAPParams) object 
  * **transformed** – **[out]** pointer to embedding produced through projection 

### void transform_sparse(const raft::handle_t &handle, int \*indptr, int \*indices, float \*data, size_t nnz, int n, int d, int \*orig_x_indptr, int \*orig_x_indices, float \*orig_x_data, size_t orig_nnz, int orig_n, float \*embedding, int embedding_n, [UMAPParams](#_CPPv4N2ML10UMAPParamsE) \*params, float \*transformed)

[Sparse](#namespaceML_1_1Sparse) transform

* **Parameters:**
  * **handle** – **[in]** raft::handle_t 
  * **indptr** – **[in]** pointer to index pointer array of input array to be inferred 
  * **indices** – **[in]** pointer to index array of input array to be inferred 
  * **data** – **[in]** pointer to data array of input array to be inferred 
  * **nnz** – **[in]** number of stored values of input array to be inferred 
  * **n** – **[in]** n_samples of input array 
  * **d** – **[in]** n_features of input array 
  * **orig_x_indptr** – **[in]** pointer to index pointer array of original training array 
  * **orig_x_indices** – **[in]** pointer to index array of original training array 
  * **orig_x_data** – **[in]** pointer to data array of original training array 
  * **orig_nnz** – **[in]** number of stored values of original training array 
  * **orig_n** – **[in]** number of rows in original training array 
  * **embedding** – **[in]** pointer to embedding created during training 
  * **embedding_n** – **[in]** number of rows in embedding created during training 
  * **params** – **[in]** pointer to [ML::UMAPParams](#classML_1_1UMAPParams) object 
  * **transformed** – **[out]** pointer to embedding produced through projection 

### void inverse_transform(const raft::handle_t &handle, float \*inv_transformed, int n, int n_features, float \*orig_X, int orig_n, int \*graph_rows, int \*graph_cols, float \*graph_vals, int nnz, float \*sigmas, float \*rhos, [UMAPParams](#_CPPv4N2ML10UMAPParamsE) \*params, int n_epochs)

Inverse transform - optimize layout in original space

* **Parameters:**
  * **handle** – **[in]** raft::handle_t 
  * **inv_transformed** – **[inout]** pointer to initial inverse-transformed positions (will be optimized in-place) 
  * **n** – **[in]** number of points to inverse transform 
  * **n_features** – **[in]** number of features in original space 
  * **orig_X** – **[in]** pointer to original training data 
  * **orig_n** – **[in]** number of rows in original training data 
  * **graph_rows** – **[in]** row indices of the inverse transform graph (COO format) 
  * **graph_cols** – **[in]** column indices of the inverse transform graph (COO format) 
  * **graph_vals** – **[in]** edge weights of the inverse transform graph 
  * **nnz** – **[in]** number of edges in the graph 
  * **sigmas** – **[in]** per-point sigma values from fuzzy simplicial set 
  * **rhos** – **[in]** per-point rho values from fuzzy simplicial set 
  * **params** – **[in]** pointer to [ML::UMAPParams](#classML_1_1UMAPParams) object 
  * **n_epochs** – **[in]** number of optimization epochs
