Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
Phpml\Classification\Ensemble\Bagging Class Reference
Inheritance diagram for Phpml\Classification\Ensemble\Bagging:
Phpml\Classification\Classifier Phpml\Estimator Phpml\Classification\Ensemble\RandomForest

Public Member Functions

 __construct (int $numClassifier=50)
 Creates an ensemble classifier with given number of base classifiers Default number of base classifiers is 50.
 
 predict (array $samples)
 
 setClassifer (string $classifier, array $classifierOptions=[])
 This method is used to set the base classifier.
 
 setSubsetRatio (float $ratio)
 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.
 
 train (array $samples, array $targets)
 

Protected Member Functions

 getRandomSubset (int $index)
 
 initClassifiers ()
 
 initSingleClassifier (Classifier $classifier)
 
 predictSample (array $sample)
 

Protected Attributes

string $classifier = DecisionTree::class
 
array $classifierOptions = ['maxDepth' => 20]
 
array $classifiers = []
 
int $featureCount = 0
 
int $numClassifier
 
int $numSamples
 
float $subsetRatio = 0.7
 

Constructor & Destructor Documentation

◆ __construct()

Phpml\Classification\Ensemble\Bagging::__construct ( int $numClassifier = 50)

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

Reimplemented in Phpml\Classification\Ensemble\RandomForest.

Member Function Documentation

◆ initSingleClassifier()

Phpml\Classification\Ensemble\Bagging::initSingleClassifier ( Classifier $classifier)
protected

◆ predict()

Phpml\Estimator::predict ( array $samples)
inherited

Implemented in Phpml\Pipeline.

◆ predictSample()

Phpml\Classification\Ensemble\Bagging::predictSample ( array $sample)
protected
Return values
mixed

◆ setClassifer()

Phpml\Classification\Ensemble\Bagging::setClassifer ( string $classifier,
array $classifierOptions = [] )

This method is used to set the base classifier.

Default value is DecisionTree\class, but any class that implements the Classifier can be used.
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 values
$this

Reimplemented in Phpml\Classification\Ensemble\RandomForest.

◆ setSubsetRatio()

Phpml\Classification\Ensemble\Bagging::setSubsetRatio ( float $ratio)

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 values
$this
Exceptions
InvalidArgumentException

◆ train()

Phpml\Classification\Ensemble\Bagging::train ( array $samples,
array $targets )

Implements Phpml\Estimator.


The documentation for this class was generated from the following file: