Random Forest Classifier. More...
#include <shark/Models/Trees/RFClassifier.h>
Public Member Functions | |
std::string | name () const |
From INameable: return the class name. | |
double | OOBerror () const |
Returns the computed out-of-bag-error of the forest. | |
RealVector const & | featureImportances () const |
Returns the computed feature importances of the forest. | |
UIntVector | countAttributes () const |
Counts how often attributes are used. | |
void | computeOOBerror (std::vector< std::vector< std::size_t > > const &oobIndices, LabeledData< RealVector, LabelType > const &data) |
Compute oob error, given an oob dataset. | |
void | computeFeatureImportances (std::vector< std::vector< std::size_t > > const &oobIndices, LabeledData< RealVector, LabelType > const &data, random::rng_type &rng) |
Public Member Functions inherited from shark::Ensemble< CARTree< LabelType > > | |
void | addModel (CARTree< LabelType > const &model, double weight=1.0) |
Adds a new model to the ensemble. | |
void | clearModels () |
Removes all models from the ensemble. | |
std::size_t | numberOfModels () const |
Returns the number of models. | |
std::remove_pointer< CARTree< LabelType > >::type & | model (std::size_t i) |
Returns a reference to the i-th model. | |
std::remove_pointer< CARTree< LabelType > >::type const & | model (std::size_t i) const |
Returns a const reference to the i-th model. | |
double const & | weight (std::size_t i) const |
Returns the weight of the i-th model. | |
double & | weight (std::size_t i) |
Returns the weight of the i-th model. | |
double | sumOfWeights () const |
Returns the total sum of weights used for averaging. | |
Random Forest Classifier.
Definition at line 61 of file RFClassifier.h.
|
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 170 of file RFClassifier.h.
References shark::inputDimension(), shark::Ensemble< CARTree< LabelType > >::numberOfModels(), shark::subBatch(), shark::Ensemble< CARTree< LabelType > >::sumOfWeights(), and shark::Ensemble< CARTree< LabelType > >::weight().
Referenced by shark::RFTrainer< unsigned int >::train(), and shark::RFTrainer< RealVector >::train().
|
inline |
Compute oob error, given an oob dataset.
Definition at line 157 of file RFClassifier.h.
References shark::LabeledData< InputT, LabelT >::numberOfElements().
Referenced by shark::RFTrainer< unsigned int >::train(), and shark::RFTrainer< RealVector >::train().
|
inline |
Counts how often attributes are used.
Definition at line 146 of file RFClassifier.h.
References shark::Ensemble< CARTree< LabelType > >::model(), and shark::Ensemble< CARTree< LabelType > >::numberOfModels().
|
inline |
Returns the computed feature importances of the forest.
Definition at line 141 of file RFClassifier.h.
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::Ensemble< CARTree< LabelType > >.
Definition at line 131 of file RFClassifier.h.
|
inline |
Returns the computed out-of-bag-error of the forest.
Definition at line 136 of file RFClassifier.h.