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

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.

## ◆ eLossType

template<class VectorType >

Multi-class loss function type.

Enumerator
elNaiveHinge
elDiscriminativeMax
elDiscriminativeSum
elTotalMax
elTotalSum

Definition at line 203 of file Pegasos.h.

## ◆ eMarginType

template<class VectorType >

Multi-class margin type.

Enumerator
emRelative
emAbsolute

Definition at line 196 of file Pegasos.h.

## Member Function Documentation

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.

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().

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.

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.

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().

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.

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
 data training data margintype margin function type losstype loss function type sumToZero enforce the sum-to-zero constraint? C SVM regularization parameter w class-wise weight vectors batchsize number of samples in each gradient estimate varepsilon solution accuracy (factor by which the primal gradient should be reduced)

Definition at line 220 of file Pegasos.h.

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