shark::McPegasos< VectorType > Class Template Reference

Pegasos solver for linear multi-class support vector machines. More...

#include <shark/Algorithms/Pegasos.h>

Public Types

enum  eMarginType { emRelative, emAbsolute }
 Multi-class margin type. More...
 
enum  eLossType {
  elNaiveHinge, elDiscriminativeMax, elDiscriminativeSum, elTotalMax,
  elTotalSum
}
 Multi-class loss function type. More...
 

Static Public Member Functions

template<class WeightType >
static std::size_t solve (LabeledData< VectorType, unsigned int > const &data, eMarginType margintype, eLossType losstype, bool sumToZero, double C, std::vector< WeightType > &w, std::size_t batchsize=1, double varepsilon=0.001)
 Solve the primal multi-class SVM problem. More...
 

Protected Types

typedef bool(* LossGradientFunction) (VectorType const &, unsigned int, RealVector const &, std::vector< VectorType > &, bool)
 

Static Protected Member Functions

static bool lossGradientANH (VectorType const &x, unsigned int y, RealVector const &f, std::vector< VectorType > &gradient, bool sumToZero)
 
static bool lossGradientRDM (VectorType const &x, unsigned int y, RealVector const &f, std::vector< VectorType > &gradient, bool sumToZero)
 
static bool lossGradientRDS (VectorType const &x, unsigned int y, RealVector const &f, std::vector< VectorType > &gradient, bool sumToZero)
 
static bool lossGradientADS (VectorType const &x, unsigned int y, RealVector const &f, std::vector< VectorType > &gradient, bool sumToZero)
 
static bool lossGradientADM (VectorType const &x, unsigned int y, RealVector const &f, std::vector< VectorType > &gradient, bool sumToZero)
 
static bool lossGradientATS (VectorType const &x, unsigned int y, RealVector const &f, std::vector< VectorType > &gradient, bool sumToZero)
 
static bool lossGradientATM (VectorType const &x, unsigned int y, RealVector const &f, std::vector< VectorType > &gradient, bool sumToZero)
 

Detailed Description

template<class VectorType>
class shark::McPegasos< VectorType >

Pegasos solver for linear multi-class support vector machines.

Definition at line 192 of file Pegasos.h.

Member Typedef Documentation

◆ LossGradientFunction

template<class VectorType >
typedef bool(* shark::McPegasos< VectorType >::LossGradientFunction) (VectorType const &, unsigned int, RealVector const &, std::vector< VectorType > &, bool)
protected

Definition at line 384 of file Pegasos.h.

Member Enumeration Documentation

◆ eLossType

template<class VectorType >
enum shark::McPegasos::eLossType

Multi-class loss function type.

Enumerator
elNaiveHinge 
elDiscriminativeMax 
elDiscriminativeSum 
elTotalMax 
elTotalSum 

Definition at line 203 of file Pegasos.h.

◆ eMarginType

template<class VectorType >
enum shark::McPegasos::eMarginType

Multi-class margin type.

Enumerator
emRelative 
emAbsolute 

Definition at line 196 of file Pegasos.h.

Member Function Documentation

◆ lossGradientADM()

template<class VectorType >
static bool shark::McPegasos< VectorType >::lossGradientADM ( VectorType const &  x,
unsigned int  y,
RealVector const &  f,
std::vector< VectorType > &  gradient,
bool  sumToZero 
)
inlinestaticprotected

Definition at line 483 of file Pegasos.h.

◆ lossGradientADS()

template<class VectorType >
static bool shark::McPegasos< VectorType >::lossGradientADS ( VectorType const &  x,
unsigned int  y,
RealVector const &  f,
std::vector< VectorType > &  gradient,
bool  sumToZero 
)
inlinestaticprotected

Definition at line 456 of file Pegasos.h.

References shark::mean().

◆ lossGradientANH()

template<class VectorType >
static bool shark::McPegasos< VectorType >::lossGradientANH ( VectorType const &  x,
unsigned int  y,
RealVector const &  f,
std::vector< VectorType > &  gradient,
bool  sumToZero 
)
inlinestaticprotected

Definition at line 387 of file Pegasos.h.

◆ lossGradientATM()

template<class VectorType >
static bool shark::McPegasos< VectorType >::lossGradientATM ( VectorType const &  x,
unsigned int  y,
RealVector const &  f,
std::vector< VectorType > &  gradient,
bool  sumToZero 
)
inlinestaticprotected

Definition at line 553 of file Pegasos.h.

◆ lossGradientATS()

template<class VectorType >
static bool shark::McPegasos< VectorType >::lossGradientATS ( VectorType const &  x,
unsigned int  y,
RealVector const &  f,
std::vector< VectorType > &  gradient,
bool  sumToZero 
)
inlinestaticprotected

Definition at line 515 of file Pegasos.h.

References shark::mean().

◆ lossGradientRDM()

template<class VectorType >
static bool shark::McPegasos< VectorType >::lossGradientRDM ( VectorType const &  x,
unsigned int  y,
RealVector const &  f,
std::vector< VectorType > &  gradient,
bool  sumToZero 
)
inlinestaticprotected

Definition at line 408 of file Pegasos.h.

◆ lossGradientRDS()

template<class VectorType >
static bool shark::McPegasos< VectorType >::lossGradientRDS ( VectorType const &  x,
unsigned int  y,
RealVector const &  f,
std::vector< VectorType > &  gradient,
bool  sumToZero 
)
inlinestaticprotected

Definition at line 435 of file Pegasos.h.

◆ solve()

template<class VectorType >
template<class WeightType >
static std::size_t shark::McPegasos< VectorType >::solve ( LabeledData< VectorType, unsigned int > const &  data,
eMarginType  margintype,
eLossType  losstype,
bool  sumToZero,
double  C,
std::vector< WeightType > &  w,
std::size_t  batchsize = 1,
double  varepsilon = 0.001 
)
inlinestatic

Solve the primal multi-class SVM problem.

In addition to "standard" Pegasos this solver checks a meaningful stopping criterion.

The function returns the number of model predictions during training (this is comparable to SMO iterations).

Parameters
datatraining data
margintypemargin function type
losstypeloss function type
sumToZeroenforce the sum-to-zero constraint?
CSVM regularization parameter
wclass-wise weight vectors
batchsizenumber of samples in each gradient estimate
varepsilonsolution accuracy (factor by which the primal gradient should be reduced)

Definition at line 220 of file Pegasos.h.

References lambda, shark::Pegasos< VectorType >::lg(), shark::LabeledData< InputT, LabelT >::numberOfElements(), SHARK_ASSERT, and SHARK_RUNTIME_CHECK.


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