PlusML
Loading...
Searching...
No Matches
Public Member Functions | List of all members
plusml::BinarySVM Class Reference

Basic binary classification SVM. More...

#include <binary_svm.h>

Public Member Functions

 BinarySVM (uint64_t features, bool bias_enabled=true)
 Constructor for BinarySVM class.
 
uint64_t Features () const
 Get number of features in each sample for the model.
 
Eigen::MatrixXf Parameters () const
 Get current parameters of the model.
 
void SetParameters (const Eigen::MatrixXf &parameters)
 Set desired parameters for the model.
 
void FitSGD (const Eigen::MatrixXf &samples, const Eigen::MatrixXf &targets, float learning_rate, float l2_alpha, uint64_t batch_size, uint64_t epochs)
 Fit model using stochastic gradient descent with given hyperparameters.
 
Eigen::MatrixXf Predict (Eigen::MatrixXf samples, bool sign=true)
 Get predictions for a given matrix of samples.
 

Detailed Description

Basic binary classification SVM.

Constructor & Destructor Documentation

◆ BinarySVM()

plusml::BinarySVM::BinarySVM ( uint64_t features,
bool bias_enabled = true )
explicit

Constructor for BinarySVM class.

Parameters
featuresNumber of features in each sample
bias_enabledSpecifies whether to use bias or not

Initializes model's parameters to zero

Member Function Documentation

◆ Features()

uint64_t plusml::BinarySVM::Features ( ) const

Get number of features in each sample for the model.

Returns
Number of features in each sample for the model

◆ FitSGD()

void plusml::BinarySVM::FitSGD ( const Eigen::MatrixXf & samples,
const Eigen::MatrixXf & targets,
float learning_rate,
float l2_alpha,
uint64_t batch_size,
uint64_t epochs )

Fit model using stochastic gradient descent with given hyperparameters.

Parameters
samplesMatrix of samples (MxN where M is number of samples and N is number of features in each sample)
targetsMatrix of targets (Mx1 where M is number of samples)
learning_rateLearning rate for SGD
l2_alphaCoefficient for L2 regularization
batch_sizeBatch size for SGD
epochsNumber of epochs for SGD

◆ Parameters()

Eigen::MatrixXf plusml::BinarySVM::Parameters ( ) const

Get current parameters of the model.

Returns
Parameters matrix

◆ Predict()

Eigen::MatrixXf plusml::BinarySVM::Predict ( Eigen::MatrixXf samples,
bool sign = true )

Get predictions for a given matrix of samples.

Parameters
samplesMatrix of samples (MxN where M is number of samples and N is number of features in each sample)
signApply the Sign function to predictions (default: true)
Returns
Matrix of predicted classes (Mx1 where M is number of samples)

◆ SetParameters()

void plusml::BinarySVM::SetParameters ( const Eigen::MatrixXf & parameters)

Set desired parameters for the model.

Parameters
parametersMatrix representing parameters to set

The documentation for this class was generated from the following files: