shark::NearestNeighborModel< InputType, unsigned int > Class Template Reference

#include <shark/Models/NearestNeighborModel.h>

+ Inheritance diagram for shark::NearestNeighborModel< InputType, unsigned int >:

Public Types

enum  DistanceWeights { UNIFORM, ONE_OVER_DISTANCE }
 Type of distance-based weights. More...
 
typedef AbstractNearestNeighbors< InputType, unsigned int > NearestNeighbors
 
- Public Types inherited from shark::Classifier< detail::BaseNearestNeighbor< InputType, unsigned int > >
typedef detail::BaseNearestNeighbor< InputType, unsigned int > ::InputType InputType
 
typedef unsigned int OutputType
 
typedef Batch< InputType >::type BatchInputType
 
typedef Batch< unsigned int >::type BatchOutputType
 
- Public Types inherited from shark::AbstractModel< detail::BaseNearestNeighbor< InputType, unsigned int > ::InputType, unsigned int >
enum  Feature
 
typedef detail::BaseNearestNeighbor< InputType, unsigned int > ::InputType InputType
 Defines the input type of the model. More...
 
typedef unsigned int OutputType
 Defines the output type of the model. More...
 
typedef AbstractModel< detail::BaseNearestNeighbor< InputType, unsigned int > ::InputType, unsigned int, RealVector > ModelBaseType
 Defines the BaseType used by the model (this type). Useful for creating derived models. 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< FeatureFeatures
 
typedef TypedFeatureNotAvailableException< FeatureFeatureNotAvailableException
 
- Public Types inherited from shark::IParameterizable< RealVector >
typedef RealVector ParameterVectorType
 

Public Member Functions

 NearestNeighborModel (NearestNeighbors const *algorithm, unsigned int neighbors=3)
 Constructor. More...
 
std::string name () const
 From INameable: return the class name. More...
 
unsigned int neighbors () const
 return the number of neighbors More...
 
void setNeighbors (unsigned int neighbors)
 set the number of neighbors More...
 
DistanceWeights getDistanceWeightType () const
 query the way distances enter as weights More...
 
void setDistanceWeightType (DistanceWeights dw)
 set the way distances enter as weights More...
 
- Public Member Functions inherited from shark::Classifier< detail::BaseNearestNeighbor< InputType, unsigned int > >
 Classifier ()
 
 Classifier (detail::BaseNearestNeighbor< InputType, unsigned int > const &decisionFunction)
 
std::string name () const
 returns the name of the object More...
 
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...
 
Shape inputShape () const
 Returns the expected shape of the input. More...
 
Shape outputShape () const
 Returns the shape of the output. More...
 
RealVector const & bias () const
 
RealVector & bias ()
 
detail::BaseNearestNeighbor< InputType, unsigned int > const & decisionFunction () const
 Return the decision function. More...
 
detail::BaseNearestNeighbor< InputType, unsigned int > & decisionFunction ()
 Return the decision function. More...
 
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. More...
 
void read (InArchive &archive)
 From ISerializable. More...
 
void write (OutArchive &archive) const
 From ISerializable. More...
 
- Public Member Functions inherited from shark::AbstractModel< detail::BaseNearestNeighbor< InputType, unsigned int > ::InputType, unsigned int >
 AbstractModel ()
 
virtual ~AbstractModel ()
 
const Featuresfeatures () const
 
virtual void updateFeatures ()
 
bool hasFirstParameterDerivative () const
 Returns true when the first parameter derivative is implemented. More...
 
bool hasFirstInputDerivative () const
 Returns true when the first input derivative is implemented. More...
 
virtual boost::shared_ptr< StatecreateState () const
 Creates an internal state of the model. More...
 
Data< OutputTypeoperator() (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 &outputs, BatchOutputType const &coefficients, State const &state, RealVector &derivative) const
 calculates the weighted sum of derivatives w.r.t the parameters. More...
 
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 More...
 
virtual void weightedDerivatives (BatchInputType const &patterns, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, RealVector &parameterDerivative, BatchInputType &inputDerivative) const
 calculates weighted input and parameter derivative at the same time More...
 
- Public Member Functions inherited from shark::IParameterizable< RealVector >
virtual ~IParameterizable ()
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 
- Public Member Functions inherited from shark::ISerializable
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 ()
 

Additional Inherited Members

- Protected Attributes inherited from shark::AbstractModel< detail::BaseNearestNeighbor< InputType, unsigned int > ::InputType, unsigned int >
Features m_features
 

Detailed Description

template<class InputType>
class shark::NearestNeighborModel< InputType, unsigned int >

Definition at line 229 of file NearestNeighborModel.h.

Member Typedef Documentation

◆ NearestNeighbors

template<class InputType >
typedef AbstractNearestNeighbors<InputType,unsigned int> shark::NearestNeighborModel< InputType, unsigned int >::NearestNeighbors

Definition at line 232 of file NearestNeighborModel.h.

Member Enumeration Documentation

◆ DistanceWeights

template<class InputType >
enum shark::NearestNeighborModel< InputType, unsigned int >::DistanceWeights

Type of distance-based weights.

Enumerator
UNIFORM 

uniform (= no) distance-based weights

ONE_OVER_DISTANCE 

weight each neighbor's label with 1/distance

Definition at line 236 of file NearestNeighborModel.h.

Constructor & Destructor Documentation

◆ NearestNeighborModel()

template<class InputType >
shark::NearestNeighborModel< InputType, unsigned int >::NearestNeighborModel ( NearestNeighbors const *  algorithm,
unsigned int  neighbors = 3 
)
inline

Constructor.

Parameters
algorithmthe used algorithm for nearest neighbor search
neighborsnumber of neighbors

Definition at line 245 of file NearestNeighborModel.h.

Member Function Documentation

◆ getDistanceWeightType()

template<class InputType >
DistanceWeights shark::NearestNeighborModel< InputType, unsigned int >::getDistanceWeightType ( ) const
inline

query the way distances enter as weights

Definition at line 264 of file NearestNeighborModel.h.

◆ name()

template<class InputType >
std::string shark::NearestNeighborModel< InputType, unsigned int >::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 250 of file NearestNeighborModel.h.

◆ neighbors()

template<class InputType >
unsigned int shark::NearestNeighborModel< InputType, unsigned int >::neighbors ( ) const
inline

return the number of neighbors

Definition at line 254 of file NearestNeighborModel.h.

◆ setDistanceWeightType()

template<class InputType >
void shark::NearestNeighborModel< InputType, unsigned int >::setDistanceWeightType ( DistanceWeights  dw)
inline

set the way distances enter as weights

Definition at line 269 of file NearestNeighborModel.h.

◆ setNeighbors()

template<class InputType >
void shark::NearestNeighborModel< InputType, unsigned int >::setNeighbors ( unsigned int  neighbors)
inline

set the number of neighbors

Definition at line 259 of file NearestNeighborModel.h.


The documentation for this class was generated from the following file: