Kernel expansion with missing features support. More...
#include <shark/Models/Kernels/MissingFeaturesKernelExpansion.h>
Public Types | |
typedef Base::KernelType | KernelType |
typedef Base::BatchInputType | BatchInputType |
typedef Base::BatchOutputType | BatchOutputType |
![]() | |
typedef AbstractKernelFunction< InputType > | KernelType |
typedef base_type::BatchInputType | BatchInputType |
typedef base_type::BatchOutputType | BatchOutputType |
![]() | |
enum | Feature |
typedef InputType | InputType |
Defines the input type of the model. More... | |
typedef RealVector | OutputType |
Defines the output type of the model. More... | |
typedef Batch< InputType >::type | BatchInputType |
defines the batch type of the input type. More... | |
typedef Batch< OutputType >::type | BatchOutputType |
defines the batch type of the output type More... | |
typedef TypedFlags< Feature > | Features |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
Public Member Functions | |
std::string | name () const |
From INameable: return the class name. More... | |
boost::shared_ptr< State > | createState () const |
Creates an internal state of the model. More... | |
virtual void | eval (BatchInputType const &patterns, BatchOutputType &outputs) const |
Override eval(...) in the base class. More... | |
void | eval (BatchInputType const &patterns, BatchOutputType &outputs, State &state) const |
Standard interface for evaluating the response of the model to a batch of patterns. More... | |
template<class InputTypeT > | |
double | computeNorm (const RealVector &alpha, const RealVector &scalingCoefficient, InputTypeT const &missingness) const |
double | computeNorm (const RealVector &alpha, const RealVector &scalingCoefficient) const |
void | setScalingCoefficients (const RealVector &scalingCoefficients) |
void | setClassifierNorm (double classifierNorm) |
MissingFeaturesKernelExpansion () | |
MissingFeaturesKernelExpansion (KernelType *kernel) | |
MissingFeaturesKernelExpansion (KernelType *kernel, Data< InputType > const &basis, bool offset) | |
![]() | |
KernelExpansion () | |
KernelExpansion (KernelType *kernel) | |
KernelExpansion (KernelType *kernel, Data< InputType > const &basis, bool offset, std::size_t outputs=1) | |
void | setStructure (KernelType *kernel, Data< InputType > const &basis, bool offset, std::size_t outputs=1) |
size_t | outputSize () const |
dimensionality of the output RealVector More... | |
KernelType const * | kernel () const |
KernelType * | kernel () |
void | setKernel (KernelType *kernel) |
bool | hasOffset () const |
RealMatrix & | alpha () |
RealMatrix const & | alpha () const |
double & | alpha (std::size_t example, std::size_t cls) |
double const & | alpha (std::size_t example, std::size_t cls) const |
RealVector & | offset () |
RealVector const & | offset () const |
double & | offset (std::size_t cls) |
double const & | offset (std::size_t cls) const |
Data< InputType > const & | basis () const |
Data< InputType > & | basis () |
void | sparsify () |
RealVector | parameterVector () const |
Return the parameter vector. More... | |
void | setParameterVector (RealVector const &newParameters) |
Set the parameter vector. More... | |
std::size_t | numberOfParameters () const |
Return the number of parameters. More... | |
void | read (InArchive &archive) |
From ISerializable, reads a model from an archive. More... | |
void | write (OutArchive &archive) const |
From ISerializable, writes a model to an archive. More... | |
![]() | |
AbstractModel () | |
virtual | ~AbstractModel () |
const Features & | features () const |
virtual void | updateFeatures () |
bool | hasFirstParameterDerivative () const |
Returns true when the first parameter derivative is implemented. More... | |
bool | hasSecondParameterDerivative () const |
Returns true when the second parameter derivative is implemented. More... | |
bool | hasFirstInputDerivative () const |
Returns true when the first input derivative is implemented. More... | |
bool | hasSecondInputDerivative () const |
Returns true when the second parameter derivative is implemented. More... | |
bool | isSequential () const |
virtual void | eval (InputType const &pattern, OutputType &output) const |
Standard interface for evaluating the response of the model to a single pattern. More... | |
Data< OutputType > | operator() (Data< InputType > const &patterns) const |
Model evaluation as an operator for a whole dataset. This is a convenience function. More... | |
OutputType | operator() (InputType const &pattern) const |
Model evaluation as an operator for a single pattern. This is a convenience function. More... | |
BatchOutputType | operator() (BatchInputType const &patterns) const |
Model evaluation as an operator for a single pattern. This is a convenience function. More... | |
virtual void | weightedParameterDerivative (BatchInputType const &pattern, BatchOutputType const &coefficients, State const &state, RealVector &derivative) const |
calculates the weighted sum of derivatives w.r.t the parameters. More... | |
virtual void | weightedParameterDerivative (BatchInputType const &pattern, BatchOutputType const &coefficients, Batch< RealMatrix >::type const &errorHessian, State const &state, RealVector &derivative, RealMatrix &hessian) const |
calculates the weighted sum of derivatives w.r.t the parameters More... | |
virtual void | weightedInputDerivative (BatchInputType const &pattern, BatchOutputType const &coefficients, State const &state, BatchInputType &derivative) const |
calculates the weighted sum of derivatives w.r.t the inputs More... | |
virtual void | weightedInputDerivative (BatchInputType const &pattern, BatchOutputType const &coefficients, typename Batch< RealMatrix >::type const &errorHessian, State const &state, RealMatrix &derivative, Batch< RealMatrix >::type &hessian) const |
calculates the weighted sum of derivatives w.r.t the inputs More... | |
virtual void | weightedDerivatives (BatchInputType const &patterns, BatchOutputType const &coefficients, State const &state, RealVector ¶meterDerivative, BatchInputType &inputDerivative) const |
calculates weighted input and parameter derivative at the same time More... | |
![]() | |
virtual | ~IParameterizable () |
![]() | |
virtual | ~INameable () |
![]() | |
virtual | ~ISerializable () |
Virtual d'tor. 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 () | |
Protected Attributes | |
RealVector | m_scalingCoefficients |
The scaling coefficients. More... | |
double | m_classifierNorm |
The norm of classifier(w) More... | |
![]() | |
KernelType * | mep_kernel |
kernel function used in the expansion More... | |
Data< InputType > | m_basis |
"support" basis vectors More... | |
RealMatrix | m_alpha |
kernel coefficients More... | |
RealVector | m_b |
offset or bias term More... | |
![]() | |
Features | m_features |
Kernel expansion with missing features support.
Definition at line 46 of file MissingFeaturesKernelExpansion.h.
typedef Base::BatchInputType shark::MissingFeaturesKernelExpansion< InputType >::BatchInputType |
Definition at line 52 of file MissingFeaturesKernelExpansion.h.
typedef Base::BatchOutputType shark::MissingFeaturesKernelExpansion< InputType >::BatchOutputType |
Definition at line 53 of file MissingFeaturesKernelExpansion.h.
typedef Base::KernelType shark::MissingFeaturesKernelExpansion< InputType >::KernelType |
Definition at line 51 of file MissingFeaturesKernelExpansion.h.
|
inline |
Constructors from the base class
Definition at line 56 of file MissingFeaturesKernelExpansion.h.
|
inline |
Definition at line 59 of file MissingFeaturesKernelExpansion.h.
|
inline |
Definition at line 63 of file MissingFeaturesKernelExpansion.h.
|
inline |
Calculate norm of classifier, i.e., ||w||
formula: \( \sum_{i,j=1}^{n}\alpha_i\frac{y_i}{s_i}K\left(x_i,x_j)\right)\frac{y_j}{s_j}\alpha_j \) where \( s_i \) is scaling coefficient, and \( K \) is kernel function, \( K\left(x_i,x_j)\right) \) is taken only over features that are valid for both \( x_i \) and \( x_j \)
Definition at line 122 of file MissingFeaturesKernelExpansion.h.
References shark::KernelExpansion< InputType >::alpha(), shark::evalSkipMissingFeatures(), shark::KernelExpansion< InputType >::m_basis, shark::KernelExpansion< InputType >::mep_kernel, shark::blas::norm_sqr(), SHARK_ASSERT, and SIZE_CHECK.
Referenced by shark::MissingFeaturesKernelExpansion< InputType >::eval(), and shark::MissingFeatureSvmTrainer< InputType, CacheType >::setMaxIterations().
|
inline |
Definition at line 154 of file MissingFeaturesKernelExpansion.h.
References shark::KernelExpansion< InputType >::alpha(), shark::evalSkipMissingFeatures(), shark::KernelExpansion< InputType >::m_basis, shark::KernelExpansion< InputType >::mep_kernel, shark::blas::norm_sqr(), SHARK_ASSERT, and SIZE_CHECK.
|
inlinevirtual |
Creates an internal state of the model.
The state is needed when the derivatives are to be calculated. Eval can store a state which is then reused to speed up the calculations of the derivatives. This also allows eval to be evaluated in parallel!
Reimplemented from shark::KernelExpansion< InputType >.
Definition at line 72 of file MissingFeaturesKernelExpansion.h.
|
inlinevirtual |
Override eval(...) in the base class.
Reimplemented from shark::KernelExpansion< InputType >.
Definition at line 77 of file MissingFeaturesKernelExpansion.h.
References shark::blas::column(), shark::MissingFeaturesKernelExpansion< InputType >::computeNorm(), shark::evalSkipMissingFeatures(), shark::KernelExpansion< InputType >::hasOffset(), shark::KernelExpansion< InputType >::m_alpha, shark::KernelExpansion< InputType >::m_b, shark::KernelExpansion< InputType >::m_basis, shark::MissingFeaturesKernelExpansion< InputType >::m_classifierNorm, shark::MissingFeaturesKernelExpansion< InputType >::m_scalingCoefficients, shark::KernelExpansion< InputType >::mep_kernel, shark::blas::noalias(), shark::KernelExpansion< InputType >::outputSize(), shark::blas::repeat(), shark::blas::row(), SHARK_ASSERT, shark::size(), shark::DataView< DatasetType >::size(), and SIZE_CHECK.
Referenced by shark::MissingFeaturesKernelExpansion< InputType >::eval().
|
inlinevirtual |
Standard interface for evaluating the response of the model to a batch of patterns.
patterns | the inputs of the model |
outputs | the predictions or response of the model to every pattern |
state | intermediate results stored by eval which can be reused for derivative computation. |
Reimplemented from shark::KernelExpansion< InputType >.
Definition at line 111 of file MissingFeaturesKernelExpansion.h.
References shark::MissingFeaturesKernelExpansion< InputType >::eval().
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::KernelExpansion< InputType >.
Definition at line 69 of file MissingFeaturesKernelExpansion.h.
|
inline |
Definition at line 195 of file MissingFeaturesKernelExpansion.h.
References shark::MissingFeaturesKernelExpansion< InputType >::m_classifierNorm, and SHARK_ASSERT.
|
inline |
Definition at line 184 of file MissingFeaturesKernelExpansion.h.
References shark::MissingFeaturesKernelExpansion< InputType >::m_scalingCoefficients, and SHARK_ASSERT.
Referenced by shark::MissingFeatureSvmTrainer< InputType, CacheType >::setMaxIterations().
|
protected |
The norm of classifier(w)
Definition at line 206 of file MissingFeaturesKernelExpansion.h.
Referenced by shark::MissingFeaturesKernelExpansion< InputType >::eval(), and shark::MissingFeaturesKernelExpansion< InputType >::setClassifierNorm().
|
protected |
The scaling coefficients.
Definition at line 203 of file MissingFeaturesKernelExpansion.h.
Referenced by shark::MissingFeaturesKernelExpansion< InputType >::eval(), and shark::MissingFeaturesKernelExpansion< InputType >::setScalingCoefficients().