Classes | |
struct | LinearSVMParams |
struct | LinearSVMModel |
class | SVC |
C-Support Vector Classification. More... | |
struct | SupportStorage |
struct | SvmModel |
struct | SvmParameter |
class | SmoSolver |
Solve the quadratic optimization problem using two level decomposition and Sequential Minimal Optimization (SMO). More... | |
class | WorkingSet |
Enumerations | |
enum | SvmType { C_SVC , NU_SVC , EPSILON_SVR , NU_SVR } |
Functions | |
template<typename math_t > | |
void | svcFit (const raft::handle_t &handle, math_t *input, int n_rows, int n_cols, math_t *labels, const SvmParameter ¶m, raft::distance::kernels::KernelParams &kernel_params, SvmModel< math_t > &model, const math_t *sample_weight) |
Fit a support vector classifier to the training data. More... | |
template<typename math_t > | |
void | svcFitSparse (const raft::handle_t &handle, int *indptr, int *indices, math_t *data, int n_rows, int n_cols, int nnz, math_t *labels, const SvmParameter ¶m, raft::distance::kernels::KernelParams &kernel_params, SvmModel< math_t > &model, const math_t *sample_weight) |
Fit a support vector classifier to the training data. More... | |
template<typename math_t > | |
void | svcPredict (const raft::handle_t &handle, math_t *input, int n_rows, int n_cols, raft::distance::kernels::KernelParams &kernel_params, const SvmModel< math_t > &model, math_t *preds, math_t buffer_size, bool predict_class) |
Predict classes or decision function value for samples in input. More... | |
template<typename math_t > | |
void | svcPredictSparse (const raft::handle_t &handle, int *indptr, int *indices, math_t *data, int n_rows, int n_cols, int nnz, raft::distance::kernels::KernelParams &kernel_params, const SvmModel< math_t > &model, math_t *preds, math_t buffer_size, bool predict_class) |
Predict classes or decision function value for samples in input. More... | |
template<typename math_t > | |
void | svmFreeBuffers (const raft::handle_t &handle, SvmModel< math_t > &m) |
template<typename math_t > | |
void | svrFit (const raft::handle_t &handle, math_t *X, int n_rows, int n_cols, math_t *y, const SvmParameter ¶m, MLCommon::Matrix::KernelParams &kernel_params, SvmModel< math_t > &model, const math_t *sample_weight=nullptr) |
Fit a support vector regressor to the training data. More... | |
template<typename math_t > | |
void | svrFitSparse (const raft::handle_t &handle, int *indptr, int *indices, math_t *data, int n_rows, int n_cols, int nnz, math_t *y, const SvmParameter ¶m, raft::distance::kernels::KernelParams &kernel_params, SvmModel< math_t > &model, const math_t *sample_weight=nullptr) |
Fit a support vector regressor to the training data. More... | |
enum ML::SVM::SvmType |
void ML::SVM::svcFit | ( | const raft::handle_t & | handle, |
math_t * | input, | ||
int | n_rows, | ||
int | n_cols, | ||
math_t * | labels, | ||
const SvmParameter & | param, | ||
raft::distance::kernels::KernelParams & | kernel_params, | ||
SvmModel< math_t > & | model, | ||
const math_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.
The output device buffers in model shall be unallocated on entry.
math_t | floating point type |
[in] | handle | the cuML handle |
[in] | input | device pointer for the input data in column major format. Size n_rows x n_cols. |
[in] | n_rows | number of rows |
[in] | n_cols | number of columns |
[in] | labels | device pointer for the labels. Size [n_rows]. |
[in] | param | parameters for training |
[in] | kernel_params | parameters for the kernel function |
[out] | model | parameters of the trained model |
[in] | sample_weight | optional sample weights, size [n_rows] |
void ML::SVM::svcFitSparse | ( | const raft::handle_t & | handle, |
int * | indptr, | ||
int * | indices, | ||
math_t * | data, | ||
int | n_rows, | ||
int | n_cols, | ||
int | nnz, | ||
math_t * | labels, | ||
const SvmParameter & | param, | ||
raft::distance::kernels::KernelParams & | kernel_params, | ||
SvmModel< math_t > & | model, | ||
const math_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.
The output device buffers in model shall be unallocated on entry.
math_t | floating point type |
[in] | handle | the cuML handle |
[in] | indptr | device pointer for CSR row positions. Size [n_rows + 1]. |
[in] | indices | device pointer for CSR column indices. Size [nnz]. |
[in] | data | device pointer for the CSR data. Size [nnz]. |
[in] | n_rows | number of rows |
[in] | n_cols | number of columns |
[in] | nnz | number of stored entries. |
[in] | labels | device pointer for the labels. Size [n_rows]. |
[in] | param | parameters for training |
[in] | kernel_params | parameters for the kernel function |
[out] | model | parameters of the trained model |
[in] | sample_weight | optional sample weights, size [n_rows] |
void ML::SVM::svcPredict | ( | const raft::handle_t & | handle, |
math_t * | input, | ||
int | n_rows, | ||
int | n_cols, | ||
raft::distance::kernels::KernelParams & | kernel_params, | ||
const SvmModel< math_t > & | model, | ||
math_t * | preds, | ||
math_t | 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.
math_t | floating point type |
handle | the cuML handle | |
[in] | input | device pointer for the input data in column major format, size [n_rows x n_cols]. |
[in] | n_rows | number of rows (input vectors) |
[in] | n_cols | number of columns (features) |
[in] | kernel_params | parameters for the kernel function |
[in] | model | SVM model parameters |
[out] | preds | device pointer to store the predicted class labels. Size [n_rows]. Should be allocated on entry. |
[in] | buffer_size | size of temporary buffer in MiB |
[in] | predict_class | whether to predict class label (true), or just return the decision function value (false) |
void ML::SVM::svcPredictSparse | ( | const raft::handle_t & | handle, |
int * | indptr, | ||
int * | indices, | ||
math_t * | data, | ||
int | n_rows, | ||
int | n_cols, | ||
int | nnz, | ||
raft::distance::kernels::KernelParams & | kernel_params, | ||
const SvmModel< math_t > & | model, | ||
math_t * | preds, | ||
math_t | 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.
math_t | floating point type |
handle | the cuML handle | |
[in] | indptr | device pointer for CSR row positions. Size [n_rows + 1]. |
[in] | indices | device pointer for CSR column indices. Size [nnz]. |
[in] | data | device pointer for the CSR data. Size [nnz]. |
[in] | n_rows | number of rows |
[in] | n_cols | number of columns |
[in] | nnz | number of stored entries. |
[in] | kernel_params | parameters for the kernel function |
[in] | model | SVM model parameters |
[out] | preds | device pointer to store the predicted class labels. Size [n_rows]. Should be allocated on entry. |
[in] | buffer_size | size of temporary buffer in MiB |
[in] | predict_class | whether to predict class label (true), or just return the decision function value (false) |
void ML::SVM::svmFreeBuffers | ( | const raft::handle_t & | handle, |
SvmModel< math_t > & | m | ||
) |
void ML::SVM::svrFit | ( | const raft::handle_t & | handle, |
math_t * | X, | ||
int | n_rows, | ||
int | n_cols, | ||
math_t * | y, | ||
const SvmParameter & | param, | ||
MLCommon::Matrix::KernelParams & | kernel_params, | ||
SvmModel< math_t > & | model, | ||
const math_t * | sample_weight = nullptr |
||
) |
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.
math_t | floating point type |
[in] | handle | the cuML handle |
[in] | X | device pointer for the input data in column major format. Size n_rows x n_cols. |
[in] | n_rows | number of rows |
[in] | n_cols | number of columns |
[in] | y | device pointer for target values. Size [n_rows]. |
[in] | param | parameters for training |
[in] | kernel_params | parameters for the kernel function |
[out] | model | parameters of the trained model |
[in] | sample_weight | optional sample weights, size [n_rows] |
void ML::SVM::svrFitSparse | ( | const raft::handle_t & | handle, |
int * | indptr, | ||
int * | indices, | ||
math_t * | data, | ||
int | n_rows, | ||
int | n_cols, | ||
int | nnz, | ||
math_t * | y, | ||
const SvmParameter & | param, | ||
raft::distance::kernels::KernelParams & | kernel_params, | ||
SvmModel< math_t > & | model, | ||
const math_t * | sample_weight = nullptr |
||
) |
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.
math_t | floating point type |
[in] | handle | the cuML handle |
[in] | indptr | device pointer for CSR row positions. Size [n_rows + 1]. |
[in] | indices | device pointer for CSR column indices. Size [nnz]. |
[in] | data | device pointer for the CSR data. Size [nnz]. |
[in] | n_rows | number of rows |
[in] | n_cols | number of columns |
[in] | nnz | number of stored entries. |
[in] | y | device pointer for target values. Size [n_rows]. |
[in] | param | parameters for training |
[in] | kernel_params | parameters for the kernel function |
[out] | model | parameters of the trained model |
[in] | sample_weight | optional sample weights, size [n_rows] |