PHP predictions processor.
More...
|
| classify ($uniqueid, stored_file $dataset, $outputdir) |
| Classifies the provided dataset samples. More...
|
|
| clear_model ($uniqueid, $modelversionoutputdir) |
| Delete the stored models. More...
|
|
| delete_output_dir ($modeloutputdir, $uniqueid) |
| Delete the output directory. More...
|
|
| estimate ($uniqueid, stored_file $dataset, $outputdir) |
| Estimates linear values for the provided dataset samples. More...
|
|
| evaluate_classification ($uniqueid, $maxdeviation, $niterations, stored_file $dataset, $outputdir, $trainedmodeldir) |
| Evaluates this processor classification model using the provided supervised learning dataset. More...
|
|
| evaluate_regression ($uniqueid, $maxdeviation, $niterations, stored_file $dataset, $outputdir, $trainedmodeldir) |
| Evaluates this processor regression model using the provided supervised learning dataset. More...
|
|
| export (string $uniqueid, string $modeldir) |
| Exports the machine learning model. More...
|
|
| import (string $uniqueid, string $modeldir, string $importdir) |
| Imports the provided machine learning model. More...
|
|
| is_ready () |
| Checks if the processor is ready to use. More...
|
|
| train_classification ($uniqueid, stored_file $dataset, $outputdir) |
| Train this processor classification model using the provided supervised learning dataset. More...
|
|
| train_regression ($uniqueid, stored_file $dataset, $outputdir) |
| Train this processor regression model using the provided supervised learning dataset. More...
|
|
|
const | BATCH_SIZE = 5000 |
| Size of training / prediction batches.
|
|
const | MODEL_FILENAME = 'model.ser' |
| File name of the serialised model.
|
|
const | TRAIN_ITERATIONS = 500 |
| Number of train iterations.
|
|
|
bool | $limitedsize = false |
|
PHP predictions processor.
- Copyright
- 2016 David Monllao
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ classify()
mlbackend_php\processor::classify |
( |
|
$uniqueid, |
|
|
stored_file |
$dataset, |
|
|
|
$outputdir |
|
) |
| |
◆ clear_model()
mlbackend_php\processor::clear_model |
( |
|
$uniqueid, |
|
|
|
$modelversionoutputdir |
|
) |
| |
Delete the stored models.
- Parameters
-
string | $uniqueid | |
string | $modelversionoutputdir | |
- Return values
-
Implements core_analytics\predictor.
◆ delete_output_dir()
mlbackend_php\processor::delete_output_dir |
( |
|
$modeloutputdir, |
|
|
|
$uniqueid |
|
) |
| |
Delete the output directory.
- Parameters
-
string | $modeloutputdir | |
string | $uniqueid | |
- Return values
-
Implements core_analytics\predictor.
◆ estimate()
mlbackend_php\processor::estimate |
( |
|
$uniqueid, |
|
|
stored_file |
$dataset, |
|
|
|
$outputdir |
|
) |
| |
Estimates linear values for the provided dataset samples.
- Exceptions
-
- Parameters
-
- Return values
-
Implements core_analytics\regressor.
◆ evaluate_classification()
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.
- Parameters
-
string | $uniqueid | |
float | $maxdeviation | |
int | $niterations | |
stored_file | $dataset | |
string | $outputdir | |
string | $trainedmodeldir | |
- Return values
-
Implements core_analytics\classifier.
◆ evaluate_regression()
mlbackend_php\processor::evaluate_regression |
( |
|
$uniqueid, |
|
|
|
$maxdeviation, |
|
|
|
$niterations, |
|
|
stored_file |
$dataset, |
|
|
|
$outputdir, |
|
|
|
$trainedmodeldir |
|
) |
| |
Evaluates this processor regression model using the provided supervised learning dataset.
- Exceptions
-
- Parameters
-
string | $uniqueid | |
float | $maxdeviation | |
int | $niterations | |
stored_file | $dataset | |
string | $outputdir | |
string | $trainedmodeldir | |
- Return values
-
Implements core_analytics\regressor.
◆ export()
mlbackend_php\processor::export |
( |
string |
$uniqueid, |
|
|
string |
$modeldir |
|
) |
| |
Exports the machine learning model.
- Exceptions
-
- Parameters
-
string | $uniqueid | The model unique id |
string | $modeldir | The directory that contains the trained model. |
- Return values
-
string | The path to the directory that contains the exported model. |
Implements core_analytics\packable.
◆ extract_metadata()
mlbackend_php\processor::extract_metadata |
( |
|
$fh | ) |
|
|
protected |
Extracts metadata from the dataset file.
The file poiter should be located at the top of the file.
- Parameters
-
- Return values
-
◆ get_evaluation_result_object()
mlbackend_php\processor::get_evaluation_result_object |
( |
\stored_file |
$dataset, |
|
|
|
$scores, |
|
|
|
$maxdeviation |
|
) |
| |
|
protected |
Returns the results objects from all evaluations.
- Parameters
-
- Return values
-
◆ get_model_filepath()
mlbackend_php\processor::get_model_filepath |
( |
string |
$modeldir | ) |
|
|
protected |
Returns the path to the serialised model file in the provided directory.
- Parameters
-
string | $modeldir | The model directory |
- Return values
-
◆ import()
mlbackend_php\processor::import |
( |
string |
$uniqueid, |
|
|
string |
$modeldir, |
|
|
string |
$importdir |
|
) |
| |
Imports the provided machine learning model.
- Parameters
-
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. |
- Return values
-
Implements core_analytics\packable.
◆ instantiate_algorithm()
mlbackend_php\processor::instantiate_algorithm |
( |
| ) |
|
|
protected |
Instantiates the ML algorithm.
- Return values
-
Phpml::Classification::Linear::LogisticRegression | |
◆ is_ready()
mlbackend_php\processor::is_ready |
( |
| ) |
|
◆ load_classifier()
mlbackend_php\processor::load_classifier |
( |
|
$outputdir | ) |
|
|
protected |
Loads the pre-trained classifier.
- Exceptions
-
- Parameters
-
- Return values
-
Phpml::Classification::Linear::LogisticRegression | |
◆ train_classification()
mlbackend_php\processor::train_classification |
( |
|
$uniqueid, |
|
|
stored_file |
$dataset, |
|
|
|
$outputdir |
|
) |
| |
Train this processor classification model using the provided supervised learning dataset.
- Parameters
-
- Return values
-
Implements core_analytics\classifier.
◆ train_regression()
mlbackend_php\processor::train_regression |
( |
|
$uniqueid, |
|
|
stored_file |
$dataset, |
|
|
|
$outputdir |
|
) |
| |
Train this processor regression model using the provided supervised learning dataset.
- Exceptions
-
- Parameters
-
- Return values
-
Implements core_analytics\regressor.
The documentation for this class was generated from the following file: