Basic linear classifier. More...
#include <shark/Models/LinearModel.h>
Inheritance diagram for shark::LinearClassifier< VectorType >:Public Types | |
| typedef LinearModel< VectorType >::MatrixType | MatrixType |
Public Types inherited from shark::Classifier< Model > | |
| typedef Model | DecisionFunctionType |
| typedef Model::InputType | InputType |
| typedef unsigned int | OutputType |
| typedef Batch< InputType >::type | BatchInputType |
| typedef Batch< unsignedint >::type | BatchOutputType |
| typedef Model::ParameterVectorType | ParameterVectorType |
Public Types inherited from shark::AbstractModel< Model::InputType, unsigned int, Model::ParameterVectorType > | |
| enum | Feature |
| typedef Model::InputType | InputType |
| Defines the input type of the model. | |
| typedef unsigned int | OutputType |
| Defines the output type of the model. | |
| typedef AbstractModel< Model::InputType, unsigned int, Model::ParameterVectorType > | ModelBaseType |
| Defines the BaseType used by the model (this type). Useful for creating derived models. | |
| typedef Batch< InputType >::type | BatchInputType |
| defines the batch type of the input type. | |
| typedef Batch< OutputType >::type | BatchOutputType |
| defines the batch type of the output type | |
| typedef TypedFlags< Feature > | Features |
| typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
Public Types inherited from shark::IParameterizable< VectorType > | |
| typedef VectorType | ParameterVectorType |
Public Member Functions | |
| LinearClassifier () | |
| LinearClassifier (Shape const &inputs, std::size_t numClasses, bool offset=false) | |
| Constructor creating a model with given dimensionalities and optional offset term. | |
| LinearClassifier (MatrixType const &matrix, VectorType const &offset=VectorType()) | |
| Constructor from weight matrix (and optional offset). | |
| std::string | name () const |
| returns the name of the object | |
| void | setStructure (Shape const &inputs, std::size_t numClasses, bool offset=false) |
| overwrite structure and parameters | |
| void | setStructure (MatrixType const &matrix, VectorType const &offset=VectorType()) |
| overwrite structure and parameters | |
Public Member Functions inherited from shark::Classifier< Model > | |
| Classifier () | |
| Classifier (Model const &decisionFunction) | |
| ParameterVectorType | parameterVector () const |
| Return the parameter vector. | |
| void | setParameterVector (ParameterVectorType const &newParameters) |
| std::size_t | numberOfParameters () const |
| Return the number of parameters. | |
| Shape | inputShape () const |
| Returns the expected shape of the input. | |
| Shape | outputShape () const |
| Returns the shape of the output. | |
| RealVector const & | bias () const |
| RealVector & | bias () |
| Model const & | decisionFunction () const |
| Return the decision function. | |
| Model & | decisionFunction () |
| Return the decision function. | |
| void | eval (BatchInputType const &input, BatchOutputType &output) const |
| void | eval (BatchInputType const &input, BatchOutputType &output, State &state) const |
| void | eval (InputType const &pattern, OutputType &output) const |
| Standard interface for evaluating the response of the model to a single pattern. | |
| void | read (InArchive &archive) |
| From ISerializable. | |
| void | write (OutArchive &archive) const |
| From ISerializable. | |
Public Member Functions inherited from shark::AbstractModel< Model::InputType, unsigned int, Model::ParameterVectorType > | |
| 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 boost::shared_ptr< State > | createState () const |
| Creates an internal state of the model. | |
| virtual void | eval (BatchInputType const &patterns, BatchOutputType &outputs) const |
| Standard interface for evaluating the response of the model to a batch of patterns. | |
| 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. | |
| 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, Model::ParameterVectorType &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, Model::ParameterVectorType ¶meterDerivative, BatchInputType &inputDerivative) const |
| calculates weighted input and parameter derivative at the same time | |
Public Member Functions inherited from shark::IParameterizable< VectorType > | |
| virtual | ~IParameterizable () |
| virtual void | setParameterVector (ParameterVectorType const &newParameters) |
| Set the parameter vector. | |
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 () | |
Additional Inherited Members | |
Protected Attributes inherited from shark::AbstractModel< Model::InputType, unsigned int, Model::ParameterVectorType > | |
| Features | m_features |
Basic linear classifier.
The LinearClassifier class is a multi class classifier model suited for linear discriminant analysis. For c classes \( 0, \dots, c-1 \) the model computes
\( \arg \max_i w_i^T x + b_i \)
Thus is it a linear model with arg max computation. The internal linear model can be queried using decisionFunction().
Definition at line 335 of file LinearModel.h.
| typedef LinearModel<VectorType>::MatrixType shark::LinearClassifier< VectorType >::MatrixType |
Definition at line 338 of file LinearModel.h.
|
inline |
Definition at line 339 of file LinearModel.h.
|
inline |
Constructor creating a model with given dimensionalities and optional offset term.
Definition at line 342 of file LinearModel.h.
References shark::LinearClassifier< VectorType >::setStructure().
|
inline |
Constructor from weight matrix (and optional offset).
Definition at line 347 of file LinearModel.h.
References shark::LinearClassifier< VectorType >::setStructure().
|
inlinevirtual |
returns the name of the object
Reimplemented from shark::Classifier< Model >.
Definition at line 351 of file LinearModel.h.
|
inline |
overwrite structure and parameters
Definition at line 360 of file LinearModel.h.
References shark::Classifier< Model >::decisionFunction().
|
inline |
overwrite structure and parameters
Definition at line 355 of file LinearModel.h.
References shark::Classifier< Model >::decisionFunction().
Referenced by shark::LinearClassifier< VectorType >::LinearClassifier(), and shark::LinearClassifier< VectorType >::LinearClassifier().