Kernel expansion with missing features support For a choice of kernel, see Kernels. More...
#include <shark/Models/Kernels/MissingFeaturesKernelExpansion.h>
Inheritance diagram for shark::MissingFeaturesKernelExpansion< InputType >:Public Member Functions | |
| std::string | name () const |
| From INameable: return the class name. | |
| boost::shared_ptr< State > | createState () const |
| Creates an internal state of the model. | |
| virtual void | eval (BatchInputType const &patterns, BatchOutputType &outputs) const |
| Override eval(...) in the base class. | |
| void | eval (BatchInputType const &patterns, BatchOutputType &outputs, State &state) const |
| Standard interface for evaluating the response of the model to a batch of patterns. | |
| 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 (KernelType *kernel) | |
| MissingFeaturesKernelExpansion (KernelType *kernel, Data< InputType > const &basis, bool offset) | |
Public Member Functions inherited from shark::KernelExpansion< InputType > | |
| 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) |
| Shape | outputShape () const |
| dimensionality of the output RealVector | |
| Shape | inputShape () const |
| Returns the expected shape of the input. | |
| 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. | |
| void | setParameterVector (RealVector const &newParameters) |
| Set the parameter vector. | |
| std::size_t | numberOfParameters () const |
| Return the number of parameters. | |
| void | read (InArchive &archive) |
| From ISerializable, reads a model from an archive. | |
| void | write (OutArchive &archive) const |
| From ISerializable, writes a model to an archive. | |
Public Member Functions inherited from shark::AbstractModel< InputType, RealVector > | |
| AbstractModel () | |
| virtual | ~AbstractModel () |
| const Features & | features () const |
| virtual void | updateFeatures () |
| bool | hasFirstParameterDerivative () const |
| Returns true when the first parameter derivative is implemented. | |
| bool | hasFirstInputDerivative () const |
| Returns true when the first input derivative is implemented. | |
| virtual void | eval (InputType const &pattern, OutputType &output) const |
| Standard interface for evaluating the response of the model to a single pattern. | |
| Data< OutputType > | operator() (Data< InputType > const &patterns) const |
| Model evaluation as an operator for a whole dataset. This is a convenience function. | |
| OutputType | operator() (InputType const &pattern) const |
| Model evaluation as an operator for a single pattern. This is a convenience function. | |
| BatchOutputType | operator() (BatchInputType const &patterns) const |
| Model evaluation as an operator for a single pattern. This is a convenience function. | |
| virtual void | weightedParameterDerivative (BatchInputType const &pattern, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, RealVector &derivative) const |
| calculates the weighted sum of derivatives w.r.t the parameters. | |
| virtual void | weightedInputDerivative (BatchInputType const &pattern, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, BatchInputType &derivative) const |
| calculates the weighted sum of derivatives w.r.t the inputs | |
| virtual void | weightedDerivatives (BatchInputType const &patterns, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, RealVector ¶meterDerivative, BatchInputType &inputDerivative) const |
| calculates weighted input and parameter derivative at the same time | |
Public Member Functions inherited from shark::IParameterizable< VectorType > | |
| virtual | ~IParameterizable () |
Public Member Functions inherited from shark::INameable | |
| virtual | ~INameable () |
Public Member Functions inherited from shark::ISerializable | |
| virtual | ~ISerializable () |
| Virtual d'tor. | |
| void | load (InArchive &archive, unsigned int version) |
| Versioned loading of components, calls read(...). | |
| void | save (OutArchive &archive, unsigned int version) const |
| Versioned storing of components, calls write(...). | |
| BOOST_SERIALIZATION_SPLIT_MEMBER () | |
Protected Attributes | |
| RealVector | m_scalingCoefficients |
| The scaling coefficients. | |
| double | m_classifierNorm |
| The norm of classifier(w) | |
Protected Attributes inherited from shark::KernelExpansion< InputType > | |
| KernelType * | mep_kernel |
| kernel function used in the expansion | |
| Data< InputType > | m_basis |
| "support" basis vectors | |
| RealMatrix | m_alpha |
| kernel coefficients | |
| RealVector | m_b |
| offset or bias term | |
Protected Attributes inherited from shark::AbstractModel< InputType, RealVector > | |
| Features | m_features |
Kernel expansion with missing features support For a choice of kernel, see Kernels.
Definition at line 45 of file MissingFeaturesKernelExpansion.h.
| typedef Base::BatchInputType shark::MissingFeaturesKernelExpansion< InputType >::BatchInputType |
Definition at line 51 of file MissingFeaturesKernelExpansion.h.
| typedef Base::BatchOutputType shark::MissingFeaturesKernelExpansion< InputType >::BatchOutputType |
Definition at line 52 of file MissingFeaturesKernelExpansion.h.
| typedef Base::KernelType shark::MissingFeaturesKernelExpansion< InputType >::KernelType |
Definition at line 50 of file MissingFeaturesKernelExpansion.h.
|
inline |
Constructors from the base class
Definition at line 55 of file MissingFeaturesKernelExpansion.h.
|
inline |
Definition at line 58 of file MissingFeaturesKernelExpansion.h.
|
inline |
Definition at line 62 of file MissingFeaturesKernelExpansion.h.
|
inline |
Definition at line 153 of file MissingFeaturesKernelExpansion.h.
References shark::KernelExpansion< InputType >::alpha(), shark::evalSkipMissingFeatures(), shark::KernelExpansion< InputType >::m_basis, shark::KernelExpansion< InputType >::mep_kernel, SHARK_ASSERT, and SIZE_CHECK.
|
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 121 of file MissingFeaturesKernelExpansion.h.
References shark::KernelExpansion< InputType >::alpha(), shark::evalSkipMissingFeatures(), shark::KernelExpansion< InputType >::m_basis, shark::KernelExpansion< InputType >::mep_kernel, SHARK_ASSERT, and SIZE_CHECK.
Referenced by shark::MissingFeaturesKernelExpansion< InputType >::eval().
|
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 71 of file MissingFeaturesKernelExpansion.h.
|
inlinevirtual |
Override eval(...) in the base class.
Reimplemented from shark::KernelExpansion< InputType >.
Definition at line 76 of file MissingFeaturesKernelExpansion.h.
References shark::batchSize(), 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::KernelExpansion< InputType >::outputShape(), SHARK_ASSERT, 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 110 of file MissingFeaturesKernelExpansion.h.
References shark::MissingFeaturesKernelExpansion< InputType >::eval().
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::KernelExpansion< InputType >.
Definition at line 68 of file MissingFeaturesKernelExpansion.h.
|
inline |
Definition at line 194 of file MissingFeaturesKernelExpansion.h.
References shark::MissingFeaturesKernelExpansion< InputType >::m_classifierNorm, and SHARK_ASSERT.
|
inline |
Definition at line 183 of file MissingFeaturesKernelExpansion.h.
References shark::MissingFeaturesKernelExpansion< InputType >::m_scalingCoefficients, and SHARK_ASSERT.
|
protected |
The norm of classifier(w)
Definition at line 205 of file MissingFeaturesKernelExpansion.h.
Referenced by shark::MissingFeaturesKernelExpansion< InputType >::eval(), and shark::MissingFeaturesKernelExpansion< InputType >::setClassifierNorm().
|
protected |
The scaling coefficients.
Definition at line 202 of file MissingFeaturesKernelExpansion.h.
Referenced by shark::MissingFeaturesKernelExpansion< InputType >::eval(), and shark::MissingFeaturesKernelExpansion< InputType >::setScalingCoefficients().