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

Training of one-class SVMs. More...

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

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

Public Types

typedef CacheType QpFloatType
 
typedef AbstractModel< InputType, RealVector > ModelType
 
typedef AbstractKernelFunction< InputTypeKernelType
 
typedef KernelMatrix< InputType, QpFloatTypeKernelMatrixType
 
typedef CachedMatrix< KernelMatrixTypeCachedMatrixType
 
typedef PrecomputedMatrix< KernelMatrixTypePrecomputedMatrixType
 
- Public Types inherited from shark::AbstractUnsupervisedTrainer< KernelExpansion< InputType > >
typedef KernelExpansion< InputTypeModelType
 
typedef KernelExpansion< InputType > ::InputType InputType
 
- Public Types inherited from shark::IParameterizable<>
typedef RealVector ParameterVectorType
 

Public Member Functions

 OneClassSvmTrainer (KernelType *kernel, double nu)
 
std::string name () const
 From INameable: return the class name. More...
 
double nu () const
 
void setNu (double nu)
 
KernelTypekernel ()
 
const KernelTypekernel () const
 
void setKernel (KernelType *kernel)
 
double 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...
 
void train (KernelExpansion< InputType > &svm, UnlabeledData< InputType > const &inputset)
 
- Public Member Functions inherited from shark::AbstractUnsupervisedTrainer< KernelExpansion< InputType > >
virtual void train (ModelType &model, const UnlabeledData< InputType > &inputset)=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 Member Functions

template<class MatrixType >
void trainSVM (KernelExpansion< InputType > &svm, UnlabeledData< InputType > const &inputset)
 

Protected Attributes

KernelTypem_kernel
 
double m_nu
 
std::size_t m_cacheSize
 
- 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::OneClassSvmTrainer< InputType, CacheType >

Training of one-class SVMs.

The one-class support vector machine is an unsupervised method for learning the high probability region of a distribution. Given are data points \( x_i, i \in \{1, \dots, m\} \), a kernel function k(x, x') and a regularization constant C > 0. Let H denote the kernel induced reproducing kernel Hilbert space of k, and let \( \phi \) denote the corresponding feature map. Then an estimate of a high probability region of the distribution generating the sample points is described by the set where the following function takes positive values:

\[ f(x) = \langle w, \phi(x) \rangle + b \]

with coefficients w and b given by the (primal) optimization problem

\[ \min \frac{1}{2} \|w\|^2 + \frac{1}{\nu m} \sum_{i=1}^m \xi_i - \rho \]

\[ \text{s.t. } \langle w, \phi(x_i) \rangle + b \geq \rho - \xi_i; \xi_i \geq 0 \]

\( 0 \leq \nu, \rho \leq 1 \) are parameters of the method for controlling the smoothness of the solution and the amount of probability mass covered.

For more details refer to the paper:

Estimating the support of a high-dimensional distribution. B. Schölkopf, J. C. Platt, J. Shawe-Taylor, A. Smola, and R. C. Williamson, 1999.

Definition at line 84 of file OneClassSvmTrainer.h.

Member Typedef Documentation

◆ CachedMatrixType

template<class InputType, class CacheType = float>
typedef CachedMatrix< KernelMatrixType > shark::OneClassSvmTrainer< InputType, CacheType >::CachedMatrixType

Definition at line 94 of file OneClassSvmTrainer.h.

◆ KernelMatrixType

template<class InputType, class CacheType = float>
typedef KernelMatrix<InputType, QpFloatType> shark::OneClassSvmTrainer< InputType, CacheType >::KernelMatrixType

Definition at line 93 of file OneClassSvmTrainer.h.

◆ KernelType

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

Definition at line 90 of file OneClassSvmTrainer.h.

◆ ModelType

template<class InputType, class CacheType = float>
typedef AbstractModel<InputType, RealVector> shark::OneClassSvmTrainer< InputType, CacheType >::ModelType

Definition at line 89 of file OneClassSvmTrainer.h.

◆ PrecomputedMatrixType

template<class InputType, class CacheType = float>
typedef PrecomputedMatrix< KernelMatrixType > shark::OneClassSvmTrainer< InputType, CacheType >::PrecomputedMatrixType

Definition at line 95 of file OneClassSvmTrainer.h.

◆ QpFloatType

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

Definition at line 88 of file OneClassSvmTrainer.h.

Constructor & Destructor Documentation

◆ OneClassSvmTrainer()

template<class InputType, class CacheType = float>
shark::OneClassSvmTrainer< InputType, CacheType >::OneClassSvmTrainer ( KernelType kernel,
double  nu 
)
inline

Definition at line 97 of file OneClassSvmTrainer.h.

Member Function Documentation

◆ CacheSize()

template<class InputType, class CacheType = float>
double shark::OneClassSvmTrainer< InputType, CacheType >::CacheSize ( ) const
inline

◆ kernel() [1/2]

template<class InputType, class CacheType = float>
KernelType* shark::OneClassSvmTrainer< InputType, CacheType >::kernel ( )
inline

◆ kernel() [2/2]

template<class InputType, class CacheType = float>
const KernelType* shark::OneClassSvmTrainer< InputType, CacheType >::kernel ( ) const
inline

◆ name()

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

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 104 of file OneClassSvmTrainer.h.

◆ nu()

template<class InputType, class CacheType = float>
double shark::OneClassSvmTrainer< InputType, CacheType >::nu ( ) const
inline

◆ numberOfParameters()

template<class InputType, class CacheType = float>
size_t shark::OneClassSvmTrainer< InputType, CacheType >::numberOfParameters ( ) const
inlinevirtual

◆ parameterVector()

template<class InputType, class CacheType = float>
RealVector shark::OneClassSvmTrainer< InputType, CacheType >::parameterVector ( ) const
inlinevirtual

◆ setCacheSize()

template<class InputType, class CacheType = float>
void shark::OneClassSvmTrainer< InputType, CacheType >::setCacheSize ( std::size_t  size)
inline

◆ setKernel()

template<class InputType, class CacheType = float>
void shark::OneClassSvmTrainer< InputType, CacheType >::setKernel ( KernelType kernel)
inline

◆ setNu()

template<class InputType, class CacheType = float>
void shark::OneClassSvmTrainer< InputType, CacheType >::setNu ( double  nu)
inline

◆ setParameterVector()

template<class InputType, class CacheType = float>
void shark::OneClassSvmTrainer< InputType, CacheType >::setParameterVector ( RealVector const &  newParameters)
inlinevirtual

◆ train()

◆ trainSVM()

template<class InputType, class CacheType = float>
template<class MatrixType >
void shark::OneClassSvmTrainer< InputType, CacheType >::trainSVM ( KernelExpansion< InputType > &  svm,
UnlabeledData< InputType > const &  inputset 
)
inlineprotected

Definition at line 165 of file OneClassSvmTrainer.h.

Member Data Documentation

◆ m_cacheSize

template<class InputType, class CacheType = float>
std::size_t shark::OneClassSvmTrainer< InputType, CacheType >::m_cacheSize
protected

◆ m_kernel

◆ m_nu


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