shark::RFClassifier Class Reference

Random Forest Classifier. More...

#include <shark/Models/Trees/RFClassifier.h>

+ Inheritance diagram for shark::RFClassifier:

Public Member Functions

std::string name () const
 From INameable: return the class name. More...
 
void computeOOBerror ()
 
void computeFeatureImportances ()
 
double const OOBerror () const
 
RealVector const & featureImportances () const
 
UIntVector countAttributes () const
 
void setLabelDimension (std::size_t in)
 Set the dimension of the labels. More...
 
void setInputDimension (std::size_t in)
 
ForestInfo getForestInfo () const
 
void setForestInfo (ForestInfo const &finfo, std::vector< double > const &weights=std::vector< double >())
 
- Public Member Functions inherited from shark::MeanModel< CARTClassifier< RealVector > >
 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 &param)
 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 (CARTClassifier< RealVector > 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...
 
- Public Member Functions inherited from shark::AbstractModel< CARTClassifier< RealVector > ::InputType, CARTClassifier< RealVector > ::OutputType >
 AbstractModel ()
 
virtual ~AbstractModel ()
 
const Featuresfeatures () 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< StatecreateState () 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< 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 &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 &parameterDerivative, BatchInputType &inputDerivative) const
 calculates weighted input and parameter derivative at the same time More...
 
- Public Member Functions inherited from shark::IParameterizable
virtual ~IParameterizable ()
 
virtual std::size_t numberOfParameters () const
 Return the number of parameters. More...
 
- 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 ()
 

Protected Attributes

std::size_t m_labelDimension
 
std::size_t m_inputDimension
 
double m_OOBerror
 
RealVector m_featureImportances
 
- Protected Attributes inherited from shark::MeanModel< CARTClassifier< RealVector > >
std::vector< CARTClassifier< RealVector > > m_models
 collection of models. More...
 
std::vector< double > m_weight
 Weight of the mean. More...
 
double m_weightSum
 Total sum of weights. More...
 
- Protected Attributes inherited from shark::AbstractModel< CARTClassifier< RealVector > ::InputType, CARTClassifier< RealVector > ::OutputType >
Features m_features
 

Additional Inherited Members

- Public Types inherited from shark::AbstractModel< CARTClassifier< RealVector > ::InputType, CARTClassifier< RealVector > ::OutputType >
enum  Feature
 
typedef CARTClassifier< RealVector > ::InputType InputType
 Defines the input type of the model. More...
 
typedef CARTClassifier< RealVector > ::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< FeatureFeatures
 
typedef TypedFeatureNotAvailableException< FeatureFeatureNotAvailableException
 

Detailed Description

Random Forest Classifier.

The Random Forest Classifier predicts a class label using the Random Forest algorithm as described in
Random Forests. Leo Breiman. Machine Learning, 1(45), pages 5-32. Springer, 2001.
It is a ensemble learner that uses multiple decision trees built using the CART methodology.

Definition at line 58 of file RFClassifier.h.

Member Function Documentation

§ computeFeatureImportances()

§ computeOOBerror()

void shark::RFClassifier::computeOOBerror ( )
inline

§ countAttributes()

UIntVector shark::RFClassifier::countAttributes ( ) const
inline

§ featureImportances()

RealVector const& shark::RFClassifier::featureImportances ( ) const
inline

Definition at line 94 of file RFClassifier.h.

References m_featureImportances.

§ getForestInfo()

ForestInfo shark::RFClassifier::getForestInfo ( ) const
inline

§ name()

std::string shark::RFClassifier::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 62 of file RFClassifier.h.

§ OOBerror()

double const shark::RFClassifier::OOBerror ( ) const
inline

Definition at line 89 of file RFClassifier.h.

References m_OOBerror.

§ setForestInfo()

void shark::RFClassifier::setForestInfo ( ForestInfo const &  finfo,
std::vector< double > const &  weights = std::vector<double>() 
)
inline

§ setInputDimension()

void shark::RFClassifier::setInputDimension ( std::size_t  in)
inline

Definition at line 115 of file RFClassifier.h.

References m_inputDimension.

§ setLabelDimension()

void shark::RFClassifier::setLabelDimension ( std::size_t  in)
inline

Set the dimension of the labels.

Definition at line 110 of file RFClassifier.h.

References m_labelDimension.

Member Data Documentation

§ m_featureImportances

RealVector shark::RFClassifier::m_featureImportances
protected

Definition at line 153 of file RFClassifier.h.

Referenced by computeFeatureImportances(), and featureImportances().

§ m_inputDimension

std::size_t shark::RFClassifier::m_inputDimension
protected

Definition at line 147 of file RFClassifier.h.

Referenced by computeFeatureImportances(), and setInputDimension().

§ m_labelDimension

std::size_t shark::RFClassifier::m_labelDimension
protected

Definition at line 144 of file RFClassifier.h.

Referenced by setLabelDimension().

§ m_OOBerror

double shark::RFClassifier::m_OOBerror
protected

Definition at line 150 of file RFClassifier.h.

Referenced by computeOOBerror(), and OOBerror().


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