Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402]
Python predictions processor
Copyright: | 2016 David Monllao {@link http://www.davidmonllao.com} |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 747 lines (25 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
processor:: (25 methods):
__construct()
is_ready()
is_webserver_ready()
is_python_server_ready()
clear_model()
delete_output_dir()
train_classification()
classify()
evaluate_classification()
export()
import()
train_regression()
estimate()
evaluate_regression()
get_file_path()
check_pip_package_version()
exec_command()
format_error_info()
get_server_url()
server_request()
add_extra_result_info()
version_check_return()
hash_dir()
zip_dir()
server_error_str()
__construct() X-Ref |
The constructor. |
is_ready() X-Ref |
Is the plugin ready to be used?. return: bool|string Returns true on success, a string detailing the error otherwise |
is_webserver_ready() X-Ref |
Checks if the python package is available in the web server executing this script. return: bool|string Returns true on success, a string detailing the error otherwise |
is_python_server_ready() X-Ref |
Checks if the server can be accessed. return: bool|string True or an error string. |
clear_model($uniqueid, $modelversionoutputdir) X-Ref |
Delete the model version output directory. param: string $uniqueid param: string $modelversionoutputdir return: null |
delete_output_dir($modeloutputdir, $uniqueid) X-Ref |
Delete the model output directory. param: string $modeloutputdir param: string $uniqueid return: null |
train_classification($uniqueid, \stored_file $dataset, $outputdir) X-Ref |
Trains a machine learning algorithm with the provided dataset. param: string $uniqueid param: \stored_file $dataset param: string $outputdir return: \stdClass |
classify($uniqueid, \stored_file $dataset, $outputdir) X-Ref |
Classifies the provided dataset samples. param: string $uniqueid param: \stored_file $dataset param: string $outputdir return: \stdClass |
evaluate_classification($uniqueid, $maxdeviation, $niterations, \stored_file $dataset,$outputdir, $trainedmodeldir) X-Ref |
Evaluates this processor classification model using the provided supervised learning dataset. param: string $uniqueid param: float $maxdeviation param: int $niterations param: \stored_file $dataset param: string $outputdir param: string $trainedmodeldir return: \stdClass |
export(string $uniqueid, string $modeldir) X-Ref |
Exports the machine learning model. param: string $uniqueid The model unique id param: string $modeldir The directory that contains the trained model. return: string The path to the directory that contains the exported model. |
import(string $uniqueid, string $modeldir, string $importdir) X-Ref |
Imports the provided machine learning model. param: string $uniqueid The model unique id param: string $modeldir The directory that will contain the trained model. param: string $importdir The directory that contains the files to import. return: bool Success |
train_regression($uniqueid, \stored_file $dataset, $outputdir) X-Ref |
Train this processor regression model using the provided supervised learning dataset. param: string $uniqueid param: \stored_file $dataset param: string $outputdir return: \stdClass |
estimate($uniqueid, \stored_file $dataset, $outputdir) X-Ref |
Estimates linear values for the provided dataset samples. param: string $uniqueid param: \stored_file $dataset param: mixed $outputdir return: void |
evaluate_regression($uniqueid, $maxdeviation, $niterations, \stored_file $dataset,$outputdir, $trainedmodeldir) X-Ref |
Evaluates this processor regression model using the provided supervised learning dataset. param: string $uniqueid param: float $maxdeviation param: int $niterations param: \stored_file $dataset param: string $outputdir param: string $trainedmodeldir return: \stdClass |
get_file_path(\stored_file $file) X-Ref |
Returns the path to the dataset file. param: \stored_file $file return: string |
check_pip_package_version($actual, $required = self::REQUIRED_PIP_PACKAGE_VERSION) X-Ref |
Check that the given package version can be used and return the error status. When evaluating the version, we assume the sematic versioning scheme as described at https://semver.org/. param: string $actual The actual Python package version param: string $required The required version of the package return: int -1 = actual version is too low, 1 = actual version too high, 0 = actual version is ok |
exec_command(string $modulename, array $params, string $errorlangstr) X-Ref |
Executes the specified module. param: string $modulename param: array $params param: string $errorlangstr return: array [0] is the result body and [1] the exit code. |
format_error_info(\stdClass $resultobj) X-Ref |
Formats the errors and info in a single info string. param: \stdClass $resultobj return: \stdClass |
get_server_url(?string $path = null) X-Ref |
Returns the url to the python ML server. param: string|null $path return: \moodle_url |
server_request($url, string $method, array $requestparams, ?array $options = null) X-Ref |
Sends a request to the python ML server. param: \moodle_url $url The requested url in the python ML server param: string $method The curl method to use param: array $requestparams Curl request params param: array|null $options Curl request options return: array [0] for the response body and [1] for the http code |
add_extra_result_info(\stdClass $resultobj) X-Ref |
Adds extra information to results info. param: \stdClass $resultobj return: \stdClass |
version_check_return($actual, $vercheck) X-Ref |
Returns the proper return value for the version checking. param: string $actual Actual moodlemlbackend version param: int $vercheck Version checking result return: true|string Returns true on success, a string detailing the error otherwise |
hash_dir(string $dir) X-Ref |
Hashes the provided dir as a string. param: string $dir Directory path return: string Hash |
zip_dir(string $dir) X-Ref |
Zips the provided directory. param: string $dir Directory path return: string The zip filename |
server_error_str(int $httpstatuscode, string $responsebody) X-Ref |
Error string for httpcode !== 200 param: int $httpstatuscode The HTTP status code param: string $responsebody The body of the response |