Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 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