Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

(no description)

File Size: 151 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

RandomForest:: (6 methods):
  __construct()
  setFeatureSubsetRatio()
  setClassifer()
  getFeatureImportances()
  setColumnNames()
  initSingleClassifier()


Class: RandomForest  - X-Ref

__construct(int $numClassifier = 50)   X-Ref
Initializes RandomForest with the given number of trees. More trees
may increase the prediction performance while it will also substantially
increase the processing time and the required memory


setFeatureSubsetRatio($ratio)   X-Ref
This method is used to determine how many of the original columns (features)
will be used to construct subsets to train base classifiers.<br>

Allowed values: 'sqrt', 'log' or any float number between 0.1 and 1.0 <br>

Default value for the ratio is 'log' which results in log(numFeatures, 2) + 1
features to be taken into consideration while selecting subspace of features

param: string|float $ratio

setClassifer(string $classifier, array $classifierOptions = [])   X-Ref
RandomForest algorithm is usable *only* with DecisionTree

return: $this

getFeatureImportances()   X-Ref
This will return an array including an importance value for
each column in the given dataset. Importance values for a column
is the average importance of that column in all trees in the forest


setColumnNames(array $names)   X-Ref
A string array to represent the columns is given. They are useful
when trying to print some information about the trees such as feature importances

return: $this

initSingleClassifier(Classifier $classifier)   X-Ref

param: DecisionTree $classifier
return: DecisionTree