Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400]

(no description)

File Size: 157 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: mixed $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

return: DecisionTree