SG++
sgpp::datadriven::PrimalDualSVM Class Reference

Implementation of a support vector machine in primal formulation which additionally stores support vectors. More...

#include <PrimalDualSVM.hpp>

Public Member Functions

void add (sgpp::base::Grid &grid, sgpp::base::DataVector &x, double alpha, size_t dataDim)
 Adds a data point to the set of support vectors. More...
 
void multiply (double scalar)
 Scales the normal vector w. More...
 
int predict (sgpp::base::Grid &grid, sgpp::base::DataVector &x, size_t dataDim)
 Class prediction for a given data point and grid. More...
 
double predictRaw (sgpp::base::Grid &grid, sgpp::base::DataVector &x, size_t dataDim, bool trans=false)
 Raw prediction for a given data point and grid. More...
 
 PrimalDualSVM (size_t dim, size_t inputDim, size_t budget, bool useBias)
 Constructor. More...
 
 ~PrimalDualSVM ()
 Destructor. More...
 

Public Attributes

base::DataVector alphas
 
base::DataVector norms
 
base::DataMatrix svs
 
base::DataVector w
 
base::DataVector w2
 

Protected Attributes

double bias
 
size_t budget
 
bool useBias
 

Detailed Description

Implementation of a support vector machine in primal formulation which additionally stores support vectors.

For non-linear classification, sparse grid kernels are applied.

Constructor & Destructor Documentation

sgpp::datadriven::PrimalDualSVM::PrimalDualSVM ( size_t  dim,
size_t  inputDim,
size_t  budget,
bool  useBias 
)

Constructor.

Parameters
dimThe dimension of the feature space (i.e. grid size)
inputDimThe dimension of the data
budgetThe max number of support vectors
useBiasIndicates whether bias should be used

References sgpp::base::DataMatrix::reserveAdditionalRows(), and svs.

sgpp::datadriven::PrimalDualSVM::~PrimalDualSVM ( )

Destructor.

Member Function Documentation

void sgpp::datadriven::PrimalDualSVM::add ( sgpp::base::Grid grid,
sgpp::base::DataVector x,
double  alpha,
size_t  dataDim 
)

Adds a data point to the set of support vectors.

Parameters
gridThe sparse grid which defines the transformation
xThe data point
alphaThe corresponding weight
dataDimDimension of x

References sgpp::base::DataVector::add(), alpha, alphas, sgpp::base::DataVector::append(), sgpp::base::DataMatrix::appendRow(), bias, budget, sgpp::op_factory::createOperationMultipleEval(), sgpp::base::DataMatrix::getNrows(), sgpp::base::Grid::getSize(), sgpp::base::DataVector::mult(), norms, svs, useBias, w, and w2.

void sgpp::datadriven::PrimalDualSVM::multiply ( double  scalar)

Scales the normal vector w.

Parameters
scalarThe scaling factor

References alphas, bias, sgpp::base::DataVector::getSize(), sgpp::base::DataVector::mult(), useBias, w, and w2.

int sgpp::datadriven::PrimalDualSVM::predict ( sgpp::base::Grid grid,
sgpp::base::DataVector x,
size_t  dataDim 
)

Class prediction for a given data point and grid.

Parameters
gridThe sparse grid which defines the transformation
xThe data point
dataDimDimension of x
Returns
The predicted class label (-1 or 1)

References predictRaw().

double sgpp::datadriven::PrimalDualSVM::predictRaw ( sgpp::base::Grid grid,
sgpp::base::DataVector x,
size_t  dataDim,
bool  trans = false 
)

Raw prediction for a given data point and grid.

Parameters
gridThe sparse grid which defines the transformation
xThe data point
dataDimDimension of x
transIndicates whether x is already transformed into feature space
Returns
The raw prediction value

References bias, sgpp::op_factory::createOperationMultipleEval(), sgpp::base::DataVector::dotProduct(), sgpp::base::Grid::getSize(), sgpp::base::DataMatrix::setRow(), useBias, and w.

Referenced by predict().

Member Data Documentation

base::DataVector sgpp::datadriven::PrimalDualSVM::alphas

Referenced by add(), and multiply().

double sgpp::datadriven::PrimalDualSVM::bias
protected

Referenced by add(), multiply(), and predictRaw().

size_t sgpp::datadriven::PrimalDualSVM::budget
protected

Referenced by add().

base::DataVector sgpp::datadriven::PrimalDualSVM::norms

Referenced by add().

base::DataMatrix sgpp::datadriven::PrimalDualSVM::svs

Referenced by add(), and PrimalDualSVM().

bool sgpp::datadriven::PrimalDualSVM::useBias
protected

Referenced by add(), multiply(), and predictRaw().

base::DataVector sgpp::datadriven::PrimalDualSVM::w

Referenced by add(), multiply(), and predictRaw().

base::DataVector sgpp::datadriven::PrimalDualSVM::w2

Referenced by add(), and multiply().


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