shark::AbstractLinearSvmTrainer< InputType > Class Template Reference

Super class of all linear SVM trainers. More...

#include <shark/Algorithms/Trainers/AbstractSvmTrainer.h>

+ Inheritance diagram for shark::AbstractLinearSvmTrainer< InputType >:

Public Types

typedef LinearClassifier< InputTypeModelType
 
- Public Types inherited from shark::AbstractTrainer< LinearClassifier< InputType >, unsigned int >
typedef LinearClassifier< InputTypeModelType
 
typedef ModelType::InputType InputType
 
typedef unsigned int LabelType
 
typedef LabeledData< InputType, LabelTypeDatasetType
 
- Public Types inherited from shark::IParameterizable<>
typedef RealVector ParameterVectorType
 

Public Member Functions

 AbstractLinearSvmTrainer (double C, bool offset, bool unconstrained)
 
double C () const
 Return the value of the regularization parameter C. More...
 
void setC (double C)
 Set the value of the regularization parameter C. More...
 
bool isUnconstrained () const
 Is the regularization parameter provided in logarithmic (unconstrained) form as a parameter? More...
 
bool trainOffset () const
 
RealVector parameterVector () const
 Get the hyper-parameter vector. More...
 
void setParameterVector (RealVector const &newParameters)
 Set the vector of hyper-parameters. More...
 
size_t numberOfParameters () const
 Return the number of hyper-parameters. More...
 
- Public Member Functions inherited from shark::AbstractTrainer< LinearClassifier< InputType >, unsigned int >
virtual void train (ModelType &model, DatasetType const &dataset)=0
 Core of the Trainer interface. More...
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 
virtual std::string name () const
 returns the name of the object More...
 
- Public Member Functions inherited from shark::ISerializable
virtual ~ISerializable ()
 Virtual d'tor. More...
 
virtual void read (InArchive &archive)
 Read the component from the supplied archive. More...
 
virtual void write (OutArchive &archive) const
 Write the component to the supplied archive. More...
 
void load (InArchive &archive, unsigned int version)
 Versioned loading of components, calls read(...). More...
 
void save (OutArchive &archive, unsigned int version) const
 Versioned storing of components, calls write(...). More...
 
 BOOST_SERIALIZATION_SPLIT_MEMBER ()
 
- Public Member Functions inherited from shark::QpConfig
 QpConfig (bool precomputedFlag=false, bool sparsifyFlag=true)
 Constructor. More...
 
QpStoppingConditionstoppingCondition ()
 Read/write access to the stopping condition. More...
 
QpStoppingCondition const & stoppingCondition () const
 Read access to the stopping condition. More...
 
QpSolutionPropertiessolutionProperties ()
 Access to the solution properties. More...
 
bool & precomputeKernel ()
 Flag for using a precomputed kernel matrix. More...
 
bool const & precomputeKernel () const
 Flag for using a precomputed kernel matrix. More...
 
bool & sparsify ()
 Flag for sparsifying the model after training. More...
 
bool const & sparsify () const
 Flag for sparsifying the model after training. More...
 
bool & shrinking ()
 Flag for shrinking in the decomposition solver. More...
 
bool const & shrinking () const
 Flag for shrinking in the decomposition solver. More...
 
bool & s2do ()
 Flag for S2DO (instead of SMO) More...
 
bool const & s2do () const
 Flag for S2DO (instead of SMO) More...
 
unsigned int & verbosity ()
 Verbosity level of the solver. More...
 
unsigned int const & verbosity () const
 Verbosity level of the solver. More...
 
unsigned long long const & accessCount () const
 Number of kernel accesses. More...
 
void setMinAccuracy (double a)
 
void setMaxIterations (unsigned long long i)
 
void setTargetValue (double v)
 
void setMaxSeconds (double s)
 
- Public Member Functions inherited from shark::IParameterizable<>
virtual ~IParameterizable ()
 

Protected Attributes

double m_C
 Regularization parameter. The exact meaning depends on the sub-class, but the value is always positive, and higher implies a less regular solution. More...
 
bool m_trainOffset
 Is the SVM trained with or without bias? More...
 
bool m_unconstrained
 Is log(C) stored internally as a parameter instead of C? If yes, then we get rid of the constraint C > 0 on the level of the parameter interface. More...
 
- Protected Attributes inherited from shark::QpConfig
QpStoppingCondition m_stoppingcondition
 conditions for when to stop the QP solver More...
 
QpSolutionProperties m_solutionproperties
 properties of the approximate solution found by the solver More...
 
bool m_precomputedKernelMatrix
 should the solver use a precomputed kernel matrix? More...
 
bool m_sparsify
 should the trainer sparsify the model after training? More...
 
bool m_shrinking
 should shrinking be used? More...
 
bool m_s2do
 should S2DO be used instead of SMO? More...
 
unsigned int m_verbosity
 verbosity level (currently unused) More...
 
unsigned long long m_accessCount
 kernel access count More...
 

Detailed Description

template<class InputType>
class shark::AbstractLinearSvmTrainer< InputType >

Super class of all linear SVM trainers.

This class is analogous to the AbstractSvmTrainer class, but for training of linear SVMs. It represents the regularization parameter of the SVM. The class also manages meta-information of the training process, like the stopping criterion and information on the actual solution.

Definition at line 320 of file AbstractSvmTrainer.h.

Member Typedef Documentation

◆ ModelType

Definition at line 327 of file AbstractSvmTrainer.h.

Constructor & Destructor Documentation

◆ AbstractLinearSvmTrainer()

template<class InputType >
shark::AbstractLinearSvmTrainer< InputType >::AbstractLinearSvmTrainer ( double  C,
bool  offset,
bool  unconstrained 
)
inline

Constructor

Parameters
Cregularization parameter - always the 'true' value of C, even when unconstrained is set
offsettrain svm with offset - this is not supported for all SVM solvers.
unconstrainedwhen a C-value is given via setParameter, should it be piped through the exp-function before using it in the solver?

Definition at line 333 of file AbstractSvmTrainer.h.

References SHARK_RUNTIME_CHECK.

Member Function Documentation

◆ C()

template<class InputType >
double shark::AbstractLinearSvmTrainer< InputType >::C ( ) const
inline

Return the value of the regularization parameter C.

Definition at line 340 of file AbstractSvmTrainer.h.

◆ isUnconstrained()

template<class InputType >
bool shark::AbstractLinearSvmTrainer< InputType >::isUnconstrained ( ) const
inline

Is the regularization parameter provided in logarithmic (unconstrained) form as a parameter?

Definition at line 350 of file AbstractSvmTrainer.h.

◆ numberOfParameters()

template<class InputType >
size_t shark::AbstractLinearSvmTrainer< InputType >::numberOfParameters ( ) const
inlinevirtual

Return the number of hyper-parameters.

Reimplemented from shark::IParameterizable<>.

Definition at line 372 of file AbstractSvmTrainer.h.

References shark::QpConfig::m_solutionproperties, shark::QpConfig::m_stoppingcondition, and shark::QpConfig::m_verbosity.

◆ parameterVector()

template<class InputType >
RealVector shark::AbstractLinearSvmTrainer< InputType >::parameterVector ( ) const
inlinevirtual

Get the hyper-parameter vector.

Reimplemented from shark::IParameterizable<>.

Definition at line 357 of file AbstractSvmTrainer.h.

◆ setC()

template<class InputType >
void shark::AbstractLinearSvmTrainer< InputType >::setC ( double  C)
inline

Set the value of the regularization parameter C.

Definition at line 344 of file AbstractSvmTrainer.h.

References SHARK_RUNTIME_CHECK.

◆ setParameterVector()

template<class InputType >
void shark::AbstractLinearSvmTrainer< InputType >::setParameterVector ( RealVector const &  newParameters)
inlinevirtual

Set the vector of hyper-parameters.

Reimplemented from shark::IParameterizable<>.

Definition at line 365 of file AbstractSvmTrainer.h.

References SHARK_ASSERT.

◆ trainOffset()

template<class InputType >
bool shark::AbstractLinearSvmTrainer< InputType >::trainOffset ( ) const
inline

Definition at line 353 of file AbstractSvmTrainer.h.

Member Data Documentation

◆ m_C

template<class InputType >
double shark::AbstractLinearSvmTrainer< InputType >::m_C
protected

Regularization parameter. The exact meaning depends on the sub-class, but the value is always positive, and higher implies a less regular solution.

Definition at line 380 of file AbstractSvmTrainer.h.

◆ m_trainOffset

template<class InputType >
bool shark::AbstractLinearSvmTrainer< InputType >::m_trainOffset
protected

Is the SVM trained with or without bias?

Definition at line 381 of file AbstractSvmTrainer.h.

◆ m_unconstrained

template<class InputType >
bool shark::AbstractLinearSvmTrainer< InputType >::m_unconstrained
protected

Is log(C) stored internally as a parameter instead of C? If yes, then we get rid of the constraint C > 0 on the level of the parameter interface.

Definition at line 382 of file AbstractSvmTrainer.h.


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