shark::MissingFeatureSvmTrainer< InputType, CacheType > Class Template Reference

Trainer for binary SVMs natively supporting missing features. More...

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

+ Inheritance diagram for shark::MissingFeatureSvmTrainer< InputType, CacheType >:

Public Member Functions

 MissingFeatureSvmTrainer (KernelType *kernel, double C, bool offset, bool unconstrained=false)
 Constructor. More...
 
std::string name () const
 From INameable: return the class name. More...
 
void train (MissingFeaturesKernelExpansion< InputType > &svm, LabeledData< InputType, unsigned int > const &dataset)
 
void setMaxIterations (std::size_t newIterations)
 
- Public Member Functions inherited from shark::AbstractSvmTrainer< InputType, unsigned int, MissingFeaturesKernelExpansion< InputType > >
 AbstractSvmTrainer (KernelType *kernel, double C, bool offset, bool unconstrained=false)
 
 AbstractSvmTrainer (KernelType *kernel, double negativeC, double positiveC, bool offset, bool unconstrained=false)
 
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...
 
RealVector const & regularizationParameters () const
 
void setRegularizationParameters (RealVector const &regularizers)
 Set the value of the regularization parameter C. More...
 
KernelTypekernel ()
 
KernelType const * kernel () const
 
void setKernel (KernelType *kernel)
 
bool isUnconstrained () const
 
bool trainOffset () const
 
std::size_t cacheSize () const
 
void setCacheSize (std::size_t size)
 
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< Model, LabelTypeT >
virtual void train (ModelType &model, DatasetType const &dataset)=0
 Core of the Trainer interface. More...
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 
- 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 Types

typedef CacheType QpFloatType
 
typedef AbstractKernelFunction< InputTypeKernelType
 

Additional Inherited Members

- Public Types inherited from shark::AbstractSvmTrainer< InputType, unsigned int, MissingFeaturesKernelExpansion< InputType > >
typedef AbstractKernelFunction< InputTypeKernelType
 
- Public Types inherited from shark::AbstractTrainer< Model, LabelTypeT >
typedef Model ModelType
 
typedef ModelType::InputType InputType
 
typedef LabelTypeT LabelType
 
typedef LabeledData< InputType, LabelTypeDatasetType
 
- Public Types inherited from shark::IParameterizable<>
typedef RealVector ParameterVectorType
 
- Protected Attributes inherited from shark::AbstractSvmTrainer< InputType, unsigned int, MissingFeaturesKernelExpansion< InputType > >
KernelTypem_kernel
 
RealVector m_regularizers
 Vector of regularization parameters. More...
 
bool m_trainOffset
 
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...
 
std::size_t m_cacheSize
 Number of values in the kernel cache. The size of the cache in bytes is the size of one entry (4 for float, 8 for double) times this number. 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 CacheType = float>
class shark::MissingFeatureSvmTrainer< InputType, CacheType >

Trainer for binary SVMs natively supporting missing features.

This is a specialized variant of the standard binary C-SVM which can be used to learn from data with missing features, without the need for prior imputation of missing values. The key idea is that each example is considered as having an instance-specific margin value, which is computed in the lower-dimensional subspace for which all features of that example are present.

The resulting optimization problem has the drawback that it is not convex any more. However, a local minimum can be easily reached by an iterative wrapper algorithm around a standard C-SVM solver. In detail, example-wise weights \( s_i \) are incorporated into the quadratic term of the standard SVM optimization problem. These take initial values of 1, and are then iteratively updated according to the instance-specific margin values. After each such update, the SVM solver is again called, and so on. Usually, between 2 and 5 iterations have been shown to be sufficient for an acceptable level of convergence.

For details, see the paper:

Max-margin Classification of Data with Absent Features Gal Chechik, Geremy Heitz, Gal Elidan, Pieter Abbeel and Daphne Koller. JMLR 2008.

Note
Much of the code in this class is borrowed from the class CSvmTrainer

Definition at line 72 of file MissingFeatureSvmTrainer.h.

Member Typedef Documentation

◆ KernelType

template<class InputType , class CacheType = float>
typedef AbstractKernelFunction<InputType> shark::MissingFeatureSvmTrainer< InputType, CacheType >::KernelType
protected

Definition at line 77 of file MissingFeatureSvmTrainer.h.

◆ QpFloatType

template<class InputType , class CacheType = float>
typedef CacheType shark::MissingFeatureSvmTrainer< InputType, CacheType >::QpFloatType
protected

Definition at line 76 of file MissingFeatureSvmTrainer.h.

Constructor & Destructor Documentation

◆ MissingFeatureSvmTrainer()

template<class InputType , class CacheType = float>
shark::MissingFeatureSvmTrainer< InputType, CacheType >::MissingFeatureSvmTrainer ( KernelType kernel,
double  C,
bool  offset,
bool  unconstrained = false 
)
inline

Constructor.

Definition at line 83 of file MissingFeatureSvmTrainer.h.

Member Function Documentation

◆ name()

template<class InputType , class CacheType = float>
std::string shark::MissingFeatureSvmTrainer< InputType, CacheType >::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 90 of file MissingFeatureSvmTrainer.h.

◆ setMaxIterations()

◆ train()


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