Calculates the weighted mean of a set of models. More...
#include <shark/Models/MeanModel.h>
Public Member Functions | |
MeanModel () | |
Constructor. More... | |
std::string | name () const |
returns the name of the object More... | |
void | eval (typename base_type::BatchInputType const &patterns, typename base_type::BatchOutputType &outputs) const |
void | eval (typename base_type::BatchInputType const &patterns, typename base_type::BatchOutputType &outputs, State &state) const |
RealVector | parameterVector () const |
This model does not have any parameters. More... | |
void | setParameterVector (const RealVector ¶m) |
This model does not have any parameters. More... | |
void | read (InArchive &archive) |
From ISerializable, reads a model from an archive. More... | |
void | write (OutArchive &archive) const |
writes a model to an archive More... | |
void | clearModels () |
Removes all models from the ensemble. More... | |
void | addModel (ModelType const &model, double weight=1.0) |
Adds a new model to the ensemble. More... | |
double const & | weight (std::size_t i) const |
Returns the weight of the i-th model. More... | |
void | setWeight (std::size_t i, double newWeight) |
sets the weight of the i-th model More... | |
std::size_t | numberOfModels () const |
Returns the number of models. 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 boost::shared_ptr< State > | createState () const |
Creates an internal state of the model. More... | |
virtual void | eval (BatchInputType const &patterns, BatchOutputType &outputs) const |
Standard interface for evaluating the response of the model to a batch of patterns. More... | |
virtual void | eval (BatchInputType const &patterns, BatchOutputType &outputs, State &state) const=0 |
Standard interface for evaluating the response of the model to a batch of patterns. More... | |
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 std::size_t | numberOfParameters () const |
Return the number of parameters. More... | |
![]() | |
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 | |
std::vector< ModelType > | m_models |
collection of models. More... | |
std::vector< double > | m_weight |
Weight of the mean. More... | |
double | m_weightSum |
Total sum of weights. More... | |
![]() | |
Features | m_features |
Additional Inherited Members | |
![]() | |
enum | Feature |
typedef ModelType::InputType | InputType |
Defines the input type of the model. More... | |
typedef ModelType::OutputType | 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 |
Calculates the weighted mean of a set of models.
Definition at line 43 of file MeanModel.h.
|
inline |
Constructor.
Definition at line 50 of file MeanModel.h.
|
inline |
Adds a new model to the ensemble.
model | the new model |
weight | weight of the model. must be > 0 |
Definition at line 100 of file MeanModel.h.
|
inline |
Removes all models from the ensemble.
Definition at line 90 of file MeanModel.h.
|
inline |
Definition at line 56 of file MeanModel.h.
Referenced by shark::MeanModel< CARTClassifier< RealVector > >::eval().
|
inline |
Definition at line 64 of file MeanModel.h.
|
inlinevirtual |
returns the name of the object
Reimplemented from shark::INameable.
Definition at line 52 of file MeanModel.h.
|
inline |
Returns the number of models.
Definition at line 119 of file MeanModel.h.
|
inlinevirtual |
This model does not have any parameters.
Reimplemented from shark::IParameterizable.
Definition at line 70 of file MeanModel.h.
|
inlinevirtual |
From ISerializable, reads a model from an archive.
Reimplemented from shark::AbstractModel< ModelType::InputType, ModelType::OutputType >.
Definition at line 78 of file MeanModel.h.
|
inlinevirtual |
This model does not have any parameters.
Reimplemented from shark::IParameterizable.
Definition at line 75 of file MeanModel.h.
|
inline |
sets the weight of the i-th model
Definition at line 113 of file MeanModel.h.
|
inline |
Returns the weight of the i-th model.
Definition at line 108 of file MeanModel.h.
Referenced by shark::MeanModel< CARTClassifier< RealVector > >::addModel().
|
inlinevirtual |
writes a model to an archive
the default implementation just saves the parameters, not the structure!
Reimplemented from shark::AbstractModel< ModelType::InputType, ModelType::OutputType >.
Definition at line 83 of file MeanModel.h.
|
protected |
collection of models.
Definition at line 125 of file MeanModel.h.
Referenced by shark::MeanModel< CARTClassifier< RealVector > >::addModel(), shark::MeanModel< CARTClassifier< RealVector > >::clearModels(), shark::MeanModel< CARTClassifier< RealVector > >::eval(), shark::MeanModel< CARTClassifier< RealVector > >::numberOfModels(), shark::MeanModel< CARTClassifier< RealVector > >::read(), and shark::MeanModel< CARTClassifier< RealVector > >::write().
|
protected |
Weight of the mean.
Definition at line 128 of file MeanModel.h.
Referenced by shark::MeanModel< CARTClassifier< RealVector > >::addModel(), shark::MeanModel< CARTClassifier< RealVector > >::clearModels(), shark::MeanModel< CARTClassifier< RealVector > >::eval(), shark::MeanModel< CARTClassifier< RealVector > >::read(), shark::MeanModel< CARTClassifier< RealVector > >::setWeight(), shark::MeanModel< CARTClassifier< RealVector > >::weight(), and shark::MeanModel< CARTClassifier< RealVector > >::write().
|
protected |
Total sum of weights.
Definition at line 131 of file MeanModel.h.
Referenced by shark::MeanModel< CARTClassifier< RealVector > >::addModel(), shark::MeanModel< CARTClassifier< RealVector > >::clearModels(), shark::MeanModel< CARTClassifier< RealVector > >::eval(), shark::MeanModel< CARTClassifier< RealVector > >::read(), shark::MeanModel< CARTClassifier< RealVector > >::setWeight(), and shark::MeanModel< CARTClassifier< RealVector > >::write().