Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Rapidsai Cuml Decomposition Params

From Leeroopedia


Knowledge Sources
Domains Machine_Learning, Dimensionality_Reduction
Last Updated 2026-02-08 12:00 GMT

Overview

Defines parameter structures and solver enumerations for PCA (Principal Component Analysis) and tSVD (Truncated Singular Value Decomposition) algorithms in cuML.

Description

This header provides a hierarchy of parameter classes used to configure PCA and tSVD decomposition operations:

  • solver enum class: Selects between divide-and-conquer (COV_EIG_DQ) and Jacobi (COV_EIG_JACOBI) eigendecomposition methods on the covariance matrix.
  • params: Base class holding matrix dimensions (n_rows, n_cols) and GPU device ID.
  • paramsSolver: Extends params with solver tolerance, iteration count, and verbosity.
  • paramsTSVDTemplate: Extends paramsSolver with the number of components and solver algorithm selection. Templated on the solver enum type.
  • paramsPCATemplate: Extends paramsTSVDTemplate with PCA-specific options (copy and whiten).

Convenience typedefs paramsTSVD, paramsPCA, paramsTSVDMG, and paramsPCAMG are provided for single-GPU and multi-GPU (MG) configurations using the solver and mg_solver enums respectively.

Usage

Use these parameter structures when calling cuML's PCA or tSVD fit/transform APIs. Instantiate the appropriate params class, set the desired fields (dimensions, solver, tolerance, number of components, etc.), and pass it to the decomposition function.

Code Reference

Source Location

  • Repository: Rapidsai_Cuml
  • File: cpp/include/cuml/decomposition/params.hpp

Signature

namespace ML {

enum class solver : int {
  COV_EIG_DQ,
  COV_EIG_JACOBI,
};

class params {
 public:
  std::size_t n_rows;
  std::size_t n_cols;
  int gpu_id = 0;
};

class paramsSolver : public params {
 public:
  float tol                  = 0.0;
  std::uint32_t n_iterations = 15;
  int verbose                = 0;
};

template <typename enum_solver = solver>
class paramsTSVDTemplate : public paramsSolver {
 public:
  std::size_t n_components = 1;
  enum_solver algorithm    = enum_solver::COV_EIG_DQ;
};

template <typename enum_solver = solver>
class paramsPCATemplate : public paramsTSVDTemplate<enum_solver> {
 public:
  bool copy   = true;
  bool whiten = false;
};

typedef paramsTSVDTemplate<> paramsTSVD;
typedef paramsPCATemplate<> paramsPCA;

enum class mg_solver { COV_EIG_DQ, COV_EIG_JACOBI };

typedef paramsPCATemplate<mg_solver> paramsPCAMG;
typedef paramsTSVDTemplate<mg_solver> paramsTSVDMG;

};  // end namespace ML

Import

#include <cuml/decomposition/params.hpp>

I/O Contract

Inputs

Name Type Required Description
n_rows std::size_t Yes Number of rows in the input matrix
n_cols std::size_t Yes Number of columns in the input matrix
gpu_id int No (default 0) GPU device ID to use
tol float No (default 0.0) Convergence tolerance for iterative solvers
n_iterations std::uint32_t No (default 15) Maximum number of iterations for the Jacobi solver
verbose int No (default 0) Verbosity level (0 = silent, 1 = print errors)
n_components std::size_t No (default 1) Number of components to keep in the decomposition
algorithm solver / mg_solver No (default COV_EIG_DQ) Eigendecomposition algorithm to use
copy bool No (default true) Whether to copy input data (PCA only)
whiten bool No (default false) Whether to whiten the output components (PCA only)

Outputs

Name Type Description
(N/A -- these are parameter structures) Configuration objects passed to PCA/tSVD APIs

Usage Examples

#include <cuml/decomposition/params.hpp>

void configure_pca() {
    // Configure PCA with Jacobi solver
    ML::paramsPCA pca_params;
    pca_params.n_rows       = 1000;
    pca_params.n_cols       = 50;
    pca_params.n_components = 10;
    pca_params.algorithm    = ML::solver::COV_EIG_JACOBI;
    pca_params.tol          = 1e-7f;
    pca_params.n_iterations = 100;
    pca_params.whiten       = true;

    // Pass pca_params to a cuML PCA fit function...
}

void configure_tsvd() {
    // Configure tSVD with divide-and-conquer solver
    ML::paramsTSVD tsvd_params;
    tsvd_params.n_rows       = 500;
    tsvd_params.n_cols       = 100;
    tsvd_params.n_components = 5;
    tsvd_params.algorithm    = ML::solver::COV_EIG_DQ;

    // Pass tsvd_params to a cuML tSVD fit function...
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment