Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

(no description)

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

Defines 1 class


Class: DecisionTree  - X-Ref

__construct(int $maxDepth = 10)   X-Ref


train(array $samples, array $targets)   X-Ref
No description

getColumnTypes(array $samples)   X-Ref
No description

getGiniIndex($baseValue, array $colValues, array $targets)   X-Ref

param: mixed $baseValue

setNumFeatures(int $numFeatures)   X-Ref
This method is used to set number of columns to be used
when deciding a split at an internal node of the tree.  <br>
If the value is given 0, then all features are used (default behaviour),
otherwise the given value will be used as a maximum for number of columns
randomly selected for each split operation.

return: $this

setColumnNames(array $names)   X-Ref
A string array to represent columns. Useful when HTML output or
column importances are desired to be inspected.

return: $this

getHtml()   X-Ref
No description

getFeatureImportances()   X-Ref
This will return an array including an importance value for
each column in the given dataset. The importance values are
normalized and their total makes 1.<br/>


getSplitLeaf(array $records, int $depth = 0)   X-Ref
No description

getBestSplit(array $records)   X-Ref
No description

getSelectedFeatures()   X-Ref
Returns available features/columns to the tree for the decision making
process. <br>

If a number is given with setNumFeatures() method, then a random selection
of features up to this number is returned. <br>

If some features are manually selected by use of setSelectedFeatures(),
then only these features are returned <br>

If any of above methods were not called beforehand, then all features
are returned by default.

preprocess(array $samples)   X-Ref
No description

isCategoricalColumn(array $columnValues)   X-Ref
No description

setSelectedFeatures(array $selectedFeatures)   X-Ref
Used to set predefined features to consider while deciding which column to use for a split


getSplitNodesByColumn(int $column, DecisionTreeLeaf $node)   X-Ref
Collects and returns an array of internal nodes that use the given
column as a split criterion


predictSample(array $sample)   X-Ref

return: mixed