PlusML
|
Class implementing multiclassification SVM. More...
#include <multiclass_svm.h>
Public Member Functions | |
MulticlassSVM (uint64_t features, uint64_t classes, ClassificationMode mode, bool bias_enabled=true) | |
Constructor for MulticlassSVM. | |
uint64_t | Features () const |
Get number of features in each sample for the model. | |
void | FitSGD (const Eigen::MatrixXf &samples, const Eigen::MatrixXi &targets, float learning_rate, float l2_alpha, uint64_t batch_size, uint64_t epochs) |
Fit model using stochastic gradient descent with given hyperparameters. | |
Eigen::MatrixXi | Predict (Eigen::MatrixXf samples) |
Get predictions for a given matrix of samples. | |
Class implementing multiclassification SVM.
Pass plusml::kOneVsOne
or plusml::kOneVsAll
to the constructor to select classification mode.
plusml::MulticlassSVM::MulticlassSVM | ( | uint64_t | features, |
uint64_t | classes, | ||
ClassificationMode | mode, | ||
bool | bias_enabled = true ) |
Constructor for MulticlassSVM.
features | Number of features in each sample |
classes | Number of classes in classification problem |
mode | Classification mode (plusml::kOneVsOne or plusml::kOneVsAll ) |
bias_enabled | Specifies whether to use bias or not |
uint64_t plusml::MulticlassSVM::Features | ( | ) | const |
Get number of features in each sample for the model.
void plusml::MulticlassSVM::FitSGD | ( | const Eigen::MatrixXf & | samples, |
const Eigen::MatrixXi & | targets, | ||
float | learning_rate, | ||
float | l2_alpha, | ||
uint64_t | batch_size, | ||
uint64_t | epochs ) |
Fit model using stochastic gradient descent with given hyperparameters.
samples | Matrix of samples (MxN where M is number of samples and N is number of features in each sample) |
targets | Matrix of targets (Mx1 where M is number of samples) |
learning_rate | Learning rate for SGD |
l2_alpha | Coefficient for L2 regularization |
batch_size | Batch size for SGD |
epochs | Number of epochs for SGD |
Eigen::MatrixXi plusml::MulticlassSVM::Predict | ( | Eigen::MatrixXf | samples | ) |
Get predictions for a given matrix of samples.
samples | Matrix of samples (MxN where M is number of samples and N is number of features in each sample) |