Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ML::SVM::LinearSVMModel< T > Struct Template Reference

#include <linear.hpp>

Collaboration diagram for ML::SVM::LinearSVMModel< T >:
Collaboration graph

Public Member Functions

std::size_t coefCols () const
 

Static Public Member Functions

static LinearSVMModel< T > fit (const raft::handle_t &handle, const LinearSVMParams &params, const T *X, const std::size_t nRows, const std::size_t nCols, const T *y, const T *sampleWeight)
 Allocate and fit the LinearSVM model. More...
 
static LinearSVMModel< T > allocate (const raft::handle_t &handle, const LinearSVMParams &params, const std::size_t nCols, const std::size_t nClasses=0)
 Explicitly allocate the data for the model without training it. More...
 
static void free (const raft::handle_t &handle, LinearSVMModel< T > &model)
 Free the allocated memory. The model is not usable after the call of this method. More...
 
static void predict (const raft::handle_t &handle, const LinearSVMParams &params, const LinearSVMModel< T > &model, const T *X, const std::size_t nRows, const std::size_t nCols, T *out)
 Predict using the trained LinearSVM model. More...
 
static void decisionFunction (const raft::handle_t &handle, const LinearSVMParams &params, const LinearSVMModel< T > &model, const T *X, const std::size_t nRows, const std::size_t nCols, T *out)
 Calculate decision function value for samples in input. More...
 
static void predictProba (const raft::handle_t &handle, const LinearSVMParams &params, const LinearSVMModel< T > &model, const T *X, const std::size_t nRows, const std::size_t nCols, const bool log, T *out)
 For SVC, predict the probabilities for each outcome. More...
 

Public Attributes

T * w
 
T * classes = nullptr
 
T * probScale = nullptr
 
std::size_t nClasses = 0
 
std::size_t coefRows
 

Member Function Documentation

◆ allocate()

template<typename T >
static LinearSVMModel<T> ML::SVM::LinearSVMModel< T >::allocate ( const raft::handle_t &  handle,
const LinearSVMParams params,
const std::size_t  nCols,
const std::size_t  nClasses = 0 
)
static

Explicitly allocate the data for the model without training it.

Parameters
[in]handlethe cuML handle.
[in]paramsthe model parameters.
[in]nColsthe number of feature dimensions.
[in]nClassesthe number of classes in the dataset (not applicable for regression).
Returns
the trained model (don't forget to call free on it after use).

◆ coefCols()

template<typename T >
std::size_t ML::SVM::LinearSVMModel< T >::coefCols ( ) const
inline

It's 1 for binary classification or regression; nClasses for multiclass.

◆ decisionFunction()

template<typename T >
static void ML::SVM::LinearSVMModel< T >::decisionFunction ( const raft::handle_t &  handle,
const LinearSVMParams params,
const LinearSVMModel< T > &  model,
const T *  X,
const std::size_t  nRows,
const std::size_t  nCols,
T *  out 
)
static

Calculate decision function value for samples in input.

Parameters
[in]handlethe cuML handle.
[in]paramsthe model parameters.
[in]modelthe trained model.
[in]Xthe input data matrix of size (nRows, nCols) in column-major format.
[in]nRowsnumber of vectors
[in]nColsnumber of features
[out]outthe decision function value of size (nRows, n_classes <= 2 ? 1 : n_classes) in row-major format.

◆ fit()

template<typename T >
static LinearSVMModel<T> ML::SVM::LinearSVMModel< T >::fit ( const raft::handle_t &  handle,
const LinearSVMParams params,
const T *  X,
const std::size_t  nRows,
const std::size_t  nCols,
const T *  y,
const T *  sampleWeight 
)
static

Allocate and fit the LinearSVM model.

Parameters
[in]handlethe cuML handle.
[in]paramsthe model parameters.
[in]Xthe input data matrix of size (nRows, nCols) in column-major format.
[in]nRowsthe number of input samples.
[in]nColsthe number of feature dimensions.
[in]ythe target - a single vector of either real (regression) or categorical (classification) values (nRows, ).
[in]sampleWeightthe non-negative weights for the training sample (nRows, ).
Returns
the trained model (don't forget to call free on it after use).

◆ free()

template<typename T >
static void ML::SVM::LinearSVMModel< T >::free ( const raft::handle_t &  handle,
LinearSVMModel< T > &  model 
)
static

Free the allocated memory. The model is not usable after the call of this method.

◆ predict()

template<typename T >
static void ML::SVM::LinearSVMModel< T >::predict ( const raft::handle_t &  handle,
const LinearSVMParams params,
const LinearSVMModel< T > &  model,
const T *  X,
const std::size_t  nRows,
const std::size_t  nCols,
T *  out 
)
static

Predict using the trained LinearSVM model.

Parameters
[in]handlethe cuML handle.
[in]paramsthe model parameters.
[in]modelthe trained model.
[in]Xthe input data matrix of size (nRows, nCols) in column-major format.
[in]nRowsthe number of input samples.
[in]nColsthe number of feature dimensions.
[out]outthe predictions (nRows, ).

◆ predictProba()

template<typename T >
static void ML::SVM::LinearSVMModel< T >::predictProba ( const raft::handle_t &  handle,
const LinearSVMParams params,
const LinearSVMModel< T > &  model,
const T *  X,
const std::size_t  nRows,
const std::size_t  nCols,
const bool  log,
T *  out 
)
static

For SVC, predict the probabilities for each outcome.

Parameters
[in]handlethe cuML handle.
[in]paramsthe model parameters.
[in]modelthe trained model.
[in]Xthe input data matrix of size (nRows, nCols) in column-major format.
[in]nRowsthe number of input samples.
[in]nColsthe number of feature dimensions.
[in]logwhether to output log-probabilities instead of probabilities.
[out]outthe estimated probabilities (nRows, nClasses) in row-major format.

Member Data Documentation

◆ classes

template<typename T >
T* ML::SVM::LinearSVMModel< T >::classes = nullptr

Sorted, unique values of input array y.

◆ coefRows

template<typename T >
std::size_t ML::SVM::LinearSVMModel< T >::coefRows

Number of rows of w, which is the number of data features plus maybe bias.

◆ nClasses

template<typename T >
std::size_t ML::SVM::LinearSVMModel< T >::nClasses = 0

Number of classes (not applicable for regression).

◆ probScale

template<typename T >
T* ML::SVM::LinearSVMModel< T >::probScale = nullptr

C-style (row-major) matrix of the probabolistic model calibration coefficients. It's empty if LinearSVMParams.probability == false. Otherwise, it's size is (2, coefCols). where coefCols = nClasses == 2 ? 1 : nClasses

◆ w

template<typename T >
T* ML::SVM::LinearSVMModel< T >::w

C-style (row-major) matrix of coefficients of size (coefRows, coefCols) where coefRows = nCols + (params.fit_intercept ? 1 : 0) coefCols = nClasses == 2 ? 1 : nClasses


The documentation for this struct was generated from the following file: