shark::QpBoxLinear< InputT > Class Template Reference

Quadratic program solver for box-constrained problems with linear kernel. More...

#include <shark/Algorithms/QP/QpBoxLinear.h>

Public Types

typedef LabeledData< InputT, unsigned int > DatasetType
 
typedef LabeledData< InputT, unsigned int >::const_element_reference ElementType
 

Public Member Functions

 QpBoxLinear (const DatasetType &dataset, std::size_t dim)
 Constructor. More...
 
void setOffset (double newOffset)
 
double offsetGradient () const
 
RealVector const & solutionWeightVector () const
 
void solve (double bound, double reg, QpStoppingCondition &stop, QpSolutionProperties *prop=NULL, bool verbose=false)
 Solve the SVM training problem. More...
 

Protected Attributes

DataView< const DatasetTypem_data
 view on training data More...
 
std::size_t m_dim
 input space dimension More...
 
RealVector m_xSquared
 diagonal entries of the quadratic matrix More...
 
RealVector m_alpha
 storage of the m_alpha values for warm start More...
 
RealVector m_weights
 storage of weight vector for warm start More...
 
RealVector m_pref
 measure of success of individual steps More...
 
double m_offset
 

Detailed Description

template<class InputT>
class shark::QpBoxLinear< InputT >

Quadratic program solver for box-constrained problems with linear kernel.

The QpBoxLinear class is a decomposition-based solver for linear support vector machine classifiers trained with the hinge loss. Its optimization is largely based on the paper
"A Dual Coordinate Descent Method for Large-scale Linear SVM" by Hsieh, Chang, and Lin, ICML, 2007. However, the present algorithm differs quite a bit, since it learns variable preferences as a replacement for the missing working set selection. At the same time, this method replaces the shrinking heuristic.

Definition at line 67 of file QpBoxLinear.h.

Member Typedef Documentation

◆ DatasetType

template<class InputT>
typedef LabeledData<InputT, unsigned int> shark::QpBoxLinear< InputT >::DatasetType

Definition at line 70 of file QpBoxLinear.h.

◆ ElementType

template<class InputT>
typedef LabeledData<InputT, unsigned int>::const_element_reference shark::QpBoxLinear< InputT >::ElementType

Definition at line 71 of file QpBoxLinear.h.

Constructor & Destructor Documentation

◆ QpBoxLinear()

template<class InputT>
shark::QpBoxLinear< InputT >::QpBoxLinear ( const DatasetType dataset,
std::size_t  dim 
)
inline

Constructor.

Parameters
datasettraining data
dimproblem dimension

Definition at line 79 of file QpBoxLinear.h.

References shark::QpBoxLinear< InputT >::m_data, shark::QpBoxLinear< InputT >::m_xSquared, and SHARK_ASSERT.

Member Function Documentation

◆ offsetGradient()

template<class InputT>
double shark::QpBoxLinear< InputT >::offsetGradient ( ) const
inline

◆ setOffset()

template<class InputT>
void shark::QpBoxLinear< InputT >::setOffset ( double  newOffset)
inline

Definition at line 99 of file QpBoxLinear.h.

References shark::QpBoxLinear< InputT >::m_offset.

◆ solutionWeightVector()

template<class InputT>
RealVector const& shark::QpBoxLinear< InputT >::solutionWeightVector ( ) const
inline

Definition at line 112 of file QpBoxLinear.h.

References shark::QpBoxLinear< InputT >::m_weights.

◆ solve()

template<class InputT>
void shark::QpBoxLinear< InputT >::solve ( double  bound,
double  reg,
QpStoppingCondition stop,
QpSolutionProperties prop = NULL,
bool  verbose = false 
)
inline

Solve the SVM training problem.

Parameters
boundupper bound for m_alpha-components, complexity parameter of the hinge loss SVM
regcoefficient of the penalty term \(-\frac{reg}{2} \cdot \|\m_alpha\|^2\), reg=1/C where C is the complexity parameter of the squared hinge loss SVM
stopstopping condition(s)
propsolution properties
verboseif true, the solver prints status information and solution statistics

Definition at line 125 of file QpBoxLinear.h.

References shark::QpBoxLinear< InputT >::m_data, and SHARK_ASSERT.

Referenced by shark::LinearCSvmTrainer< InputType >::train(), and shark::SquaredHingeLinearCSvmTrainer< InputType >::train().

Member Data Documentation

◆ m_alpha

template<class InputT>
RealVector shark::QpBoxLinear< InputT >::m_alpha
protected

storage of the m_alpha values for warm start

Definition at line 329 of file QpBoxLinear.h.

Referenced by shark::QpBoxLinear< InputT >::offsetGradient().

◆ m_data

template<class InputT>
DataView<const DatasetType> shark::QpBoxLinear< InputT >::m_data
protected

◆ m_dim

template<class InputT>
std::size_t shark::QpBoxLinear< InputT >::m_dim
protected

input space dimension

Definition at line 327 of file QpBoxLinear.h.

◆ m_offset

template<class InputT>
double shark::QpBoxLinear< InputT >::m_offset
protected

Definition at line 332 of file QpBoxLinear.h.

Referenced by shark::QpBoxLinear< InputT >::setOffset().

◆ m_pref

template<class InputT>
RealVector shark::QpBoxLinear< InputT >::m_pref
protected

measure of success of individual steps

Definition at line 331 of file QpBoxLinear.h.

◆ m_weights

template<class InputT>
RealVector shark::QpBoxLinear< InputT >::m_weights
protected

storage of weight vector for warm start

Definition at line 330 of file QpBoxLinear.h.

Referenced by shark::QpBoxLinear< InputT >::solutionWeightVector().

◆ m_xSquared

template<class InputT>
RealVector shark::QpBoxLinear< InputT >::m_xSquared
protected

diagonal entries of the quadratic matrix

Definition at line 328 of file QpBoxLinear.h.

Referenced by shark::QpBoxLinear< InputT >::QpBoxLinear().


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