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 403]

(no description)

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

Defines 1 class

Bagging:: (8 methods):
  __construct()
  setSubsetRatio()
  setClassifer()
  train()
  getRandomSubset()
  initClassifiers()
  initSingleClassifier()
  predictSample()


Class: Bagging  - X-Ref

__construct(int $numClassifier = 50)   X-Ref
Creates an ensemble classifier with given number of base classifiers
Default number of base classifiers is 50.
The more number of base classifiers, the better performance but at the cost of procesing time


setSubsetRatio(float $ratio)   X-Ref
This method determines the ratio of samples used to create the 'bootstrap' subset,
e.g., random samples drawn from the original dataset with replacement (allow repeats),
to train each base classifier.

return: $this

setClassifer(string $classifier, array $classifierOptions = [])   X-Ref
This method is used to set the base classifier. Default value is
DecisionTree::class, but any class that implements the <i>Classifier</i>
can be used. <br>
While giving the parameters of the classifier, the values should be
given in the order they are in the constructor of the classifier and parameter
names are neglected.

return: $this

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

getRandomSubset(int $index)   X-Ref
No description

initClassifiers()   X-Ref
No description

initSingleClassifier(Classifier $classifier)   X-Ref
No description

predictSample(array $sample)   X-Ref

return: mixed