Training of one-class SVMs. More...
#include <shark/Algorithms/Trainers/OneClassSvmTrainer.h>
Public Types | |
typedef CacheType | QpFloatType |
typedef AbstractModel< InputType, RealVector > | ModelType |
typedef AbstractKernelFunction< InputType > | KernelType |
typedef KernelMatrix< InputType, QpFloatType > | KernelMatrixType |
typedef CachedMatrix< KernelMatrixType > | CachedMatrixType |
typedef PrecomputedMatrix< KernelMatrixType > | PrecomputedMatrixType |
Public Types inherited from shark::AbstractUnsupervisedTrainer< KernelExpansion< InputType > > | |
typedef KernelExpansion< InputType > | ModelType |
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) |
KernelType * | kernel () |
const KernelType * | kernel () 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... | |
QpStoppingCondition & | stoppingCondition () |
Read/write access to the stopping condition. More... | |
QpStoppingCondition const & | stoppingCondition () const |
Read access to the stopping condition. More... | |
QpSolutionProperties & | solutionProperties () |
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 | |
KernelType * | m_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... | |
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.
typedef CachedMatrix< KernelMatrixType > shark::OneClassSvmTrainer< InputType, CacheType >::CachedMatrixType |
Definition at line 94 of file OneClassSvmTrainer.h.
typedef KernelMatrix<InputType, QpFloatType> shark::OneClassSvmTrainer< InputType, CacheType >::KernelMatrixType |
Definition at line 93 of file OneClassSvmTrainer.h.
typedef AbstractKernelFunction<InputType> shark::OneClassSvmTrainer< InputType, CacheType >::KernelType |
Definition at line 90 of file OneClassSvmTrainer.h.
typedef AbstractModel<InputType, RealVector> shark::OneClassSvmTrainer< InputType, CacheType >::ModelType |
Definition at line 89 of file OneClassSvmTrainer.h.
typedef PrecomputedMatrix< KernelMatrixType > shark::OneClassSvmTrainer< InputType, CacheType >::PrecomputedMatrixType |
Definition at line 95 of file OneClassSvmTrainer.h.
typedef CacheType shark::OneClassSvmTrainer< InputType, CacheType >::QpFloatType |
Definition at line 88 of file OneClassSvmTrainer.h.
|
inline |
Definition at line 97 of file OneClassSvmTrainer.h.
|
inline |
Definition at line 118 of file OneClassSvmTrainer.h.
References shark::OneClassSvmTrainer< InputType, CacheType >::m_cacheSize.
|
inline |
Definition at line 111 of file OneClassSvmTrainer.h.
References shark::OneClassSvmTrainer< InputType, CacheType >::m_kernel.
Referenced by shark::OneClassSvmTrainer< InputType, CacheType >::setKernel().
|
inline |
Definition at line 113 of file OneClassSvmTrainer.h.
References shark::OneClassSvmTrainer< InputType, CacheType >::m_kernel.
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 104 of file OneClassSvmTrainer.h.
|
inline |
Definition at line 107 of file OneClassSvmTrainer.h.
References shark::OneClassSvmTrainer< InputType, CacheType >::m_nu.
Referenced by shark::OneClassSvmTrainer< InputType, CacheType >::setNu().
|
inlinevirtual |
return the number of hyper-parameters
Reimplemented from shark::IParameterizable<>.
Definition at line 141 of file OneClassSvmTrainer.h.
References shark::OneClassSvmTrainer< InputType, CacheType >::m_kernel, and shark::IParameterizable< VectorType >::numberOfParameters().
|
inlinevirtual |
get the hyper-parameter vector
Reimplemented from shark::IParameterizable<>.
Definition at line 124 of file OneClassSvmTrainer.h.
References shark::OneClassSvmTrainer< InputType, CacheType >::m_kernel, and shark::IParameterizable< VectorType >::numberOfParameters().
|
inline |
Definition at line 120 of file OneClassSvmTrainer.h.
References shark::OneClassSvmTrainer< InputType, CacheType >::m_cacheSize.
|
inline |
Definition at line 115 of file OneClassSvmTrainer.h.
References shark::OneClassSvmTrainer< InputType, CacheType >::kernel(), and shark::OneClassSvmTrainer< InputType, CacheType >::m_kernel.
|
inline |
Definition at line 109 of file OneClassSvmTrainer.h.
References shark::OneClassSvmTrainer< InputType, CacheType >::m_nu, and shark::OneClassSvmTrainer< InputType, CacheType >::nu().
|
inlinevirtual |
set the vector of hyper-parameters
Reimplemented from shark::IParameterizable<>.
Definition at line 133 of file OneClassSvmTrainer.h.
References shark::OneClassSvmTrainer< InputType, CacheType >::m_kernel, shark::IParameterizable< VectorType >::numberOfParameters(), shark::IParameterizable< VectorType >::setParameterVector(), and SHARK_ASSERT.
|
inline |
Definition at line 144 of file OneClassSvmTrainer.h.
References shark::OneClassSvmTrainer< InputType, CacheType >::m_kernel, shark::OneClassSvmTrainer< InputType, CacheType >::m_nu, shark::QpConfig::precomputeKernel(), shark::KernelExpansion< InputType >::setStructure(), SHARK_RUNTIME_CHECK, and shark::QpConfig::sparsify().
Referenced by main().
|
inlineprotected |
Definition at line 165 of file OneClassSvmTrainer.h.
|
protected |
Definition at line 162 of file OneClassSvmTrainer.h.
Referenced by shark::OneClassSvmTrainer< InputType, CacheType >::CacheSize(), and shark::OneClassSvmTrainer< InputType, CacheType >::setCacheSize().
|
protected |
Definition at line 160 of file OneClassSvmTrainer.h.
Referenced by shark::OneClassSvmTrainer< InputType, CacheType >::kernel(), shark::OneClassSvmTrainer< InputType, CacheType >::numberOfParameters(), shark::OneClassSvmTrainer< InputType, CacheType >::parameterVector(), shark::OneClassSvmTrainer< InputType, CacheType >::setKernel(), shark::OneClassSvmTrainer< InputType, CacheType >::setParameterVector(), and shark::OneClassSvmTrainer< InputType, CacheType >::train().
|
protected |
Definition at line 161 of file OneClassSvmTrainer.h.
Referenced by shark::OneClassSvmTrainer< InputType, CacheType >::nu(), shark::OneClassSvmTrainer< InputType, CacheType >::setNu(), and shark::OneClassSvmTrainer< InputType, CacheType >::train().