Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
|
PHP predictions processor. More...
Public Member Functions | |
classify ($uniqueid, stored_file $dataset, $outputdir) | |
Classifies the provided dataset samples. | |
clear_model ($uniqueid, $modelversionoutputdir) | |
Delete the stored models. | |
delete_output_dir ($modeloutputdir, $uniqueid) | |
Delete the output directory. | |
estimate ($uniqueid, stored_file $dataset, $outputdir) | |
Estimates linear values for the provided dataset samples. | |
evaluate_classification ($uniqueid, $maxdeviation, $niterations, stored_file $dataset, $outputdir, $trainedmodeldir) | |
Evaluates this processor classification model using the provided supervised learning dataset. | |
evaluate_regression ($uniqueid, $maxdeviation, $niterations, stored_file $dataset, $outputdir, $trainedmodeldir) | |
Evaluates this processor regression model using the provided supervised learning dataset. | |
export (string $uniqueid, string $modeldir) | |
Exports the machine learning model. | |
import (string $uniqueid, string $modeldir, string $importdir) | |
Imports the provided machine learning model. | |
is_ready () | |
Checks if the processor is ready to use. | |
train_classification ($uniqueid, stored_file $dataset, $outputdir) | |
Train this processor classification model using the provided supervised learning dataset. | |
train_regression ($uniqueid, stored_file $dataset, $outputdir) | |
Train this processor regression model using the provided supervised learning dataset. | |
Protected Member Functions | |
extract_metadata ($fh) | |
Extracts metadata from the dataset file. | |
get_evaluation_result_object (\stored_file $dataset, $scores, $maxdeviation) | |
Returns the results objects from all evaluations. | |
get_model_filepath (string $modeldir) | |
Returns the path to the serialised model file in the provided directory. | |
instantiate_algorithm () | |
Instantiates the ML algorithm. | |
load_classifier ($outputdir) | |
Loads the pre-trained classifier. | |
Protected Attributes | |
bool | $limitedsize = false |
PHP predictions processor.
mlbackend_php\processor::classify | ( | $uniqueid, | |
stored_file | $dataset, | ||
$outputdir ) |
Classifies the provided dataset samples.
string | $uniqueid | |
stored_file | $dataset | |
string | $outputdir |
stdClass |
Implements core_analytics\classifier.
mlbackend_php\processor::clear_model | ( | $uniqueid, | |
$modelversionoutputdir ) |
Delete the stored models.
string | $uniqueid | |
string | $modelversionoutputdir |
null |
Implements core_analytics\predictor.
mlbackend_php\processor::delete_output_dir | ( | $modeloutputdir, | |
$uniqueid ) |
Delete the output directory.
string | $modeloutputdir | |
string | $uniqueid |
null |
Implements core_analytics\predictor.
mlbackend_php\processor::estimate | ( | $uniqueid, | |
stored_file | $dataset, | ||
$outputdir ) |
Estimates linear values for the provided dataset samples.
new | coding_exception |
string | $uniqueid | |
stored_file | $dataset | |
mixed | $outputdir |
void |
Implements core_analytics\regressor.
mlbackend_php\processor::evaluate_classification | ( | $uniqueid, | |
$maxdeviation, | |||
$niterations, | |||
stored_file | $dataset, | ||
$outputdir, | |||
$trainedmodeldir ) |
Evaluates this processor classification model using the provided supervised learning dataset.
During evaluation we need to shuffle the evaluation dataset samples to detect deviated results, if the dataset is massive we can not load everything into memory. We know that 2GB is the minimum memory limit we should have (core_analytics\model\heavy_duty_mode), if we substract the memory that we already consumed and the memory that Phpml algorithms will need we should still have at least 500MB of memory, which should be enough to evaluate a model. In any case this is a robust solution that will work for all sites but it should minimize memory limit problems. Site admins can still set $CFG->mlbackend_php_no_evaluation_limits to true to skip this 500MB limit.
string | $uniqueid | |
float | $maxdeviation | |
int | $niterations | |
stored_file | $dataset | |
string | $outputdir | |
string | $trainedmodeldir |
stdClass |
Implements core_analytics\classifier.
mlbackend_php\processor::evaluate_regression | ( | $uniqueid, | |
$maxdeviation, | |||
$niterations, | |||
stored_file | $dataset, | ||
$outputdir, | |||
$trainedmodeldir ) |
Evaluates this processor regression model using the provided supervised learning dataset.
new | coding_exception |
string | $uniqueid | |
float | $maxdeviation | |
int | $niterations | |
stored_file | $dataset | |
string | $outputdir | |
string | $trainedmodeldir |
stdClass |
Implements core_analytics\regressor.
mlbackend_php\processor::export | ( | string | $uniqueid, |
string | $modeldir ) |
Exports the machine learning model.
moodle_exception |
string | $uniqueid | The model unique id |
string | $modeldir | The directory that contains the trained model. |
string | The path to the directory that contains the exported model. |
Implements core_analytics\packable.
|
protected |
Extracts metadata from the dataset file.
The file poiter should be located at the top of the file.
resource | $fh |
array |
|
protected |
Returns the results objects from all evaluations.
stored_file | $dataset | |
array | $scores | |
float | $maxdeviation |
stdClass |
|
protected |
Returns the path to the serialised model file in the provided directory.
string | $modeldir | The model directory |
string | The model file |
mlbackend_php\processor::import | ( | string | $uniqueid, |
string | $modeldir, | ||
string | $importdir ) |
Imports the provided machine learning model.
string | $uniqueid | The model unique id |
string | $modeldir | The directory that will contain the trained model. |
string | $importdir | The directory that contains the files to import. |
bool | Success |
Implements core_analytics\packable.
|
protected |
Instantiates the ML algorithm.
Phpml\Classification\Linear\LogisticRegression |
mlbackend_php\processor::is_ready | ( | ) |
|
protected |
Loads the pre-trained classifier.
moodle_exception |
string | $outputdir |
Phpml\Classification\Linear\LogisticRegression |
mlbackend_php\processor::train_classification | ( | $uniqueid, | |
stored_file | $dataset, | ||
$outputdir ) |
Train this processor classification model using the provided supervised learning dataset.
string | $uniqueid | |
stored_file | $dataset | |
string | $outputdir |
stdClass |
Implements core_analytics\classifier.
mlbackend_php\processor::train_regression | ( | $uniqueid, | |
stored_file | $dataset, | ||
$outputdir ) |
Train this processor regression model using the provided supervised learning dataset.
new | coding_exception |
string | $uniqueid | |
stored_file | $dataset | |
string | $outputdir |
stdClass |
Implements core_analytics\regressor.