Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
Phpml\Helper Namespace Reference

  More...

Namespaces

namespace  Optimizer
  
 

Functions

 getClassifierCopy ()
 Returns an instance of the current class after cleaning up OneVsRest stuff.
 
 predictProbability (array $sample, string $label)
 Each classifier that make use of OvR approach should be able to return a probability for a sample to belong to the given label.
 
 predictSample (array $sample)
 
 predictSampleBinary (array $sample)
 Each classifier should implement this method instead of predictSample()
 
 reset ()
 Resets the classifier and the vars internally used by OneVsRest to create multiple classifiers.
 
 resetBinary ()
 To be overwritten by OneVsRest classifiers.
 
 train (array $samples, array $targets)
 Train a binary classifier in the OvR style.
 
 trainBinary (array $samples, array $targets, array $labels)
 Each classifier should implement this method instead of train(samples, targets)
 
 trainByLabel (array $samples, array $targets, array $allLabels=[])
 

Variables

array $allLabels = []
 All provided training targets' labels.
 
array $costValues = []
 
trait OneVsRest
 
trait Predictable
 
trait Trainable
 

Detailed Description

 

Function Documentation

◆ predictProbability()

Phpml\Helper\predictProbability ( array $sample,
string $label )
abstractprotected

Each classifier that make use of OvR approach should be able to return a probability for a sample to belong to the given label.

Return values
mixed

◆ predictSample()

Phpml\Helper\predictSample ( array $sample)
protected
Return values
mixed

◆ predictSampleBinary()

Phpml\Helper\predictSampleBinary ( array $sample)
abstractprotected

Each classifier should implement this method instead of predictSample()

Return values
mixed

Variable Documentation

◆ OneVsRest

trait Phpml::Helper\OneVsRest
Initial value:
{
protected array $classifiers = []

◆ Predictable

trait Phpml::Helper\Predictable
Initial value:
{
public function predict(array $samples)
{
if (!is_array($samples[0])) {
return $this->predictSample($samples);
}
$predicted = [];
foreach ($samples as $index => $sample) {
$predicted[$index] = $this->predictSample($sample);
}
return $predicted;
}
abstract protected function predictSample(array $sample)
predictSample(array $sample)
Definition OneVsRest.php:105

◆ Trainable

trait Phpml::Helper\Trainable
Initial value:
{
private array $samples = []