shark::RFClassifier< LabelType > Class Template Reference

Random Forest Classifier. More...

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

+ Inheritance diagram for shark::RFClassifier< LabelType >:

Public Member Functions

std::string name () const
 From INameable: return the class name. More...
 
double OOBerror () const
 Returns the computed out-of-bag-error of the forest. More...
 
RealVector const & featureImportances () const
 Returns the computed feature importances of the forest. More...
 
UIntVector countAttributes () const
 Counts how often attributes are used. More...
 
void computeOOBerror (std::vector< std::vector< std::size_t > > const &oobIndices, LabeledData< RealVector, LabelType > const &data)
 Compute oob error, given an oob dataset (Classification) More...
 
void computeFeatureImportances (std::vector< std::vector< std::size_t > > const &oobIndices, LabeledData< RealVector, LabelType > const &data, random::rng_type &rng)
 

Detailed Description

template<class LabelType>
class shark::RFClassifier< LabelType >

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 an ensemble learner that uses multiple decision trees built using the CART methodology.

Definition at line 154 of file RFClassifier.h.

Member Function Documentation

◆ computeFeatureImportances()

template<class LabelType>
void shark::RFClassifier< LabelType >::computeFeatureImportances ( std::vector< std::vector< std::size_t > > const &  oobIndices,
LabeledData< RealVector, LabelType > const &  data,
random::rng_type &  rng 
)
inline

Compute feature importances, given an oob dataset

For each tree, extracts the out-of-bag-samples indicated by oobIndices. The feature importance is defined as the average change of loss (Squared loss or accuracy depending on label type) when the feature is permuted across the oob samples of a tree.

Definition at line 197 of file RFClassifier.h.

References shark::inputDimension(), and shark::subBatch().

◆ computeOOBerror()

template<class LabelType>
void shark::RFClassifier< LabelType >::computeOOBerror ( std::vector< std::vector< std::size_t > > const &  oobIndices,
LabeledData< RealVector, LabelType > const &  data 
)
inline

Compute oob error, given an oob dataset (Classification)

Definition at line 184 of file RFClassifier.h.

References shark::LabeledData< InputT, LabelT >::numberOfElements().

◆ countAttributes()

template<class LabelType>
UIntVector shark::RFClassifier< LabelType >::countAttributes ( ) const
inline

Counts how often attributes are used.

Definition at line 173 of file RFClassifier.h.

◆ featureImportances()

template<class LabelType>
RealVector const& shark::RFClassifier< LabelType >::featureImportances ( ) const
inline

Returns the computed feature importances of the forest.

Definition at line 168 of file RFClassifier.h.

◆ name()

template<class LabelType>
std::string shark::RFClassifier< LabelType >::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 158 of file RFClassifier.h.

◆ OOBerror()

template<class LabelType>
double shark::RFClassifier< LabelType >::OOBerror ( ) const
inline

Returns the computed out-of-bag-error of the forest.

Definition at line 163 of file RFClassifier.h.


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