MDL-59211 analytics: Make cibot happy
Part of MDL-57791 epic.
This commit is contained in:
@@ -35,11 +35,19 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class processor implements \core_analytics\predictor {
|
||||
|
||||
/**
|
||||
* The required version of the python package that performs all calculations.
|
||||
*/
|
||||
const REQUIRED_PIP_PACKAGE_VERSION = '0.0.9';
|
||||
|
||||
/**
|
||||
* Is the plugin ready to be used?.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_ready() {
|
||||
|
||||
# Check the installed pip package version.
|
||||
// Check the installed pip package version.
|
||||
$cmd = 'python -m moodleinspire.version';
|
||||
|
||||
$output = null;
|
||||
@@ -63,8 +71,17 @@ class processor implements \core_analytics\predictor {
|
||||
return get_string('pythonpackagenotinstalled', 'mlbackend_python', $cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trains a machine learning algorithm with the provided dataset.
|
||||
*
|
||||
* @param string $uniqueid
|
||||
* @param \stored_file $dataset
|
||||
* @param string $outputdir
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function train($uniqueid, \stored_file $dataset, $outputdir) {
|
||||
|
||||
// Obtain the physical route to the file.
|
||||
$datasetpath = $this->get_file_path($dataset);
|
||||
|
||||
$cmd = 'python -m moodleinspire.training ' .
|
||||
@@ -95,8 +112,17 @@ class processor implements \core_analytics\predictor {
|
||||
return $resultobj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns predictions for the provided dataset samples.
|
||||
*
|
||||
* @param string $uniqueid
|
||||
* @param \stored_file $dataset
|
||||
* @param string $outputdir
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function predict($uniqueid, \stored_file $dataset, $outputdir) {
|
||||
|
||||
// Obtain the physical route to the file.
|
||||
$datasetpath = $this->get_file_path($dataset);
|
||||
|
||||
$cmd = 'python -m moodleinspire.prediction ' .
|
||||
@@ -127,8 +153,19 @@ class processor implements \core_analytics\predictor {
|
||||
return $resultobj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the provided dataset.
|
||||
*
|
||||
* @param string $uniqueid
|
||||
* @param float $maxdeviation
|
||||
* @param int $niterations
|
||||
* @param \stored_file $dataset
|
||||
* @param string $outputdir
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function evaluate($uniqueid, $maxdeviation, $niterations, \stored_file $dataset, $outputdir) {
|
||||
|
||||
// Obtain the physical route to the file.
|
||||
$datasetpath = $this->get_file_path($dataset);
|
||||
|
||||
$cmd = 'python -m moodleinspire.evaluation ' .
|
||||
@@ -158,6 +195,12 @@ class processor implements \core_analytics\predictor {
|
||||
return $resultobj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the dataset file.
|
||||
*
|
||||
* @param \stored_file $file
|
||||
* @return string
|
||||
*/
|
||||
protected function get_file_path(\stored_file $file) {
|
||||
// From moodle filesystem to the local file system.
|
||||
// This is not ideal, but there is no read access to moodle filesystem files.
|
||||
|
||||
@@ -1,4 +1,26 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'mlbackend_python'
|
||||
*
|
||||
* @package mlbackend_python
|
||||
* @copyright 2017 David Monllao {@link http://www.davidmonllao.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['packageinstalledshouldbe'] = '"moodleinspire" python package should be updated. The required version is "{$a->required}" and the installed version is "{$a->installed}"';
|
||||
$string['pluginname'] = 'Python machine learning backend';
|
||||
|
||||
Reference in New Issue
Block a user