RTrees
The class implements the random forest predictor.
See
REF: ml_intro_rtreesMember of Ml
-
Returns the variable importance array. The method returns the variable importance vector, computed at the training stage when CalculateVarImportance is set to true. If this flag was set to false, the empty matrix is returned.
-
Creates the empty model. Use StatModel::train to train the model, StatModel::train to create and train the model, Algorithm::load to load the pre-trained model.
Declaration
Objective-C
+ (nonnull RTrees *)create;
Swift
class func create() -> RTrees
-
Loads and creates a serialized RTree from a file
Use RTree::save to serialize and store an RTree to disk. Load the RTree from this file again, by calling this function with the path to the file. Optionally specify the node for the file containing the classifier
Declaration
Objective-C
+ (nonnull RTrees *)load:(nonnull NSString *)filepath nodeName:(nonnull NSString *)nodeName;
Swift
class func load(filepath: String, nodeName: String) -> RTrees
Parameters
filepath
path to serialized RTree
nodeName
name of node containing the classifier
-
Loads and creates a serialized RTree from a file
Use RTree::save to serialize and store an RTree to disk. Load the RTree from this file again, by calling this function with the path to the file. Optionally specify the node for the file containing the classifier
Declaration
Objective-C
+ (nonnull RTrees *)load:(nonnull NSString *)filepath;
Swift
class func load(filepath: String) -> RTrees
Parameters
filepath
path to serialized RTree
-
Declaration
Objective-C
- (nonnull TermCriteria *)getTermCriteria;
Swift
func getTermCriteria() -> TermCriteria
-
Declaration
Objective-C
- (BOOL)getCalculateVarImportance;
Swift
func getCalculateVarImportance() -> Bool
-
Declaration
Objective-C
- (int)getActiveVarCount;
Swift
func getActiveVarCount() -> Int32
-
Returns the result of each individual tree in the forest. In case the model is a regression problem, the method will return each of the trees’ results for each of the sample cases. If the model is a classifier, it will return a Mat with samples + 1 rows, where the first row gives the class number and the following rows return the votes each class had for each sample.
Declaration
Parameters
samples
Array containing the samples for which votes will be calculated.
results
Array where the result of the calculation will be written.
flags
Flags for defining the type of RTrees.
-
getActiveVarCount - see:
-getActiveVarCount:
Declaration
Objective-C
- (void)setActiveVarCount:(int)val;
Swift
func setActiveVarCount(val: Int32)
-
getCalculateVarImportance - see:
-getCalculateVarImportance:
Declaration
Objective-C
- (void)setCalculateVarImportance:(BOOL)val;
Swift
func setCalculateVarImportance(val: Bool)
-
getTermCriteria - see:
-getTermCriteria:
Declaration
Objective-C
- (void)setTermCriteria:(nonnull TermCriteria *)val;
Swift
func setTermCriteria(val: TermCriteria)