diff --git a/analytics/classes/classifier.php b/analytics/classes/classifier.php new file mode 100644 index 00000000000..be0d3a09ae1 --- /dev/null +++ b/analytics/classes/classifier.php @@ -0,0 +1,69 @@ +. + +/** + * Classifier interface. + * + * @package core_analytics + * @copyright 2017 David Monllao {@link http://www.davidmonllao.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace core_analytics; + +defined('MOODLE_INTERNAL') || die(); + +/** + * Classifier interface. + * + * @package core_analytics + * @copyright 2016 David Monllao {@link http://www.davidmonllao.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +interface classifier extends predictor { + + /** + * Train this processor classification model using the provided supervised learning dataset. + * + * @param string $uniqueid + * @param \stored_file $dataset + * @param string $outputdir + * @return \stdClass + */ + public function train_classification($uniqueid, \stored_file $dataset, $outputdir); + + /** + * Classifies the provided dataset samples. + * + * @param string $uniqueid + * @param \stored_file $dataset + * @param string $outputdir + * @return \stdClass + */ + public function classify($uniqueid, \stored_file $dataset, $outputdir); + + /** + * 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 + * @return \stdClass + */ + public function evaluate_classification($uniqueid, $maxdeviation, $niterations, \stored_file $dataset, $outputdir); +} diff --git a/analytics/classes/predictor.php b/analytics/classes/predictor.php index 277c6a96dd2..4b4548b4084 100644 --- a/analytics/classes/predictor.php +++ b/analytics/classes/predictor.php @@ -41,69 +41,4 @@ interface predictor { * @return bool */ public function is_ready(); - - /** - * Train this processor classification model using the provided supervised learning dataset. - * - * @param string $uniqueid - * @param \stored_file $dataset - * @param string $outputdir - * @return \stdClass - */ - public function train_classification($uniqueid, \stored_file $dataset, $outputdir); - - /** - * Classifies the provided dataset samples. - * - * @param string $uniqueid - * @param \stored_file $dataset - * @param string $outputdir - * @return \stdClass - */ - public function classify($uniqueid, \stored_file $dataset, $outputdir); - - /** - * 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 - * @return \stdClass - */ - public function evaluate_classification($uniqueid, $maxdeviation, $niterations, \stored_file $dataset, $outputdir); - - /** - * Train this processor regression model using the provided supervised learning dataset. - * - * @param string $uniqueid - * @param \stored_file $dataset - * @param string $outputdir - * @return \stdClass - */ - public function train_regression($uniqueid, \stored_file $dataset, $outputdir); - - /** - * Estimates linear values for the provided dataset samples. - * - * @param string $uniqueid - * @param \stored_file $dataset - * @param mixed $outputdir - * @return void - */ - public function estimate($uniqueid, \stored_file $dataset, $outputdir); - - /** - * 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 - * @return \stdClass - */ - public function evaluate_regression($uniqueid, $maxdeviation, $niterations, \stored_file $dataset, $outputdir); - } diff --git a/analytics/classes/regressor.php b/analytics/classes/regressor.php new file mode 100644 index 00000000000..c2d2a89abc5 --- /dev/null +++ b/analytics/classes/regressor.php @@ -0,0 +1,69 @@ +. + +/** + * Regressors interface. + * + * @package core_analytics + * @copyright 2017 David Monllao {@link http://www.davidmonllao.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace core_analytics; + +defined('MOODLE_INTERNAL') || die(); + +/** + * Regressors interface. + * + * @package core_analytics + * @copyright 2016 David Monllao {@link http://www.davidmonllao.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +interface regressor extends predictor { + + /** + * Train this processor regression model using the provided supervised learning dataset. + * + * @param string $uniqueid + * @param \stored_file $dataset + * @param string $outputdir + * @return \stdClass + */ + public function train_regression($uniqueid, \stored_file $dataset, $outputdir); + + /** + * Estimates linear values for the provided dataset samples. + * + * @param string $uniqueid + * @param \stored_file $dataset + * @param mixed $outputdir + * @return void + */ + public function estimate($uniqueid, \stored_file $dataset, $outputdir); + + /** + * 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 + * @return \stdClass + */ + public function evaluate_regression($uniqueid, $maxdeviation, $niterations, \stored_file $dataset, $outputdir); +} diff --git a/lib/mlbackend/php/classes/processor.php b/lib/mlbackend/php/classes/processor.php index f6a2922b06b..99458a140c4 100644 --- a/lib/mlbackend/php/classes/processor.php +++ b/lib/mlbackend/php/classes/processor.php @@ -38,7 +38,7 @@ use Phpml\ModelManager; * @copyright 2016 David Monllao {@link http://www.davidmonllao.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class processor implements \core_analytics\predictor { +class processor implements \core_analytics\classifier, \core_analytics\regressor { /** * Size of training / prediction batches. diff --git a/lib/mlbackend/python/classes/processor.php b/lib/mlbackend/python/classes/processor.php index 570c91e767a..84889e21235 100644 --- a/lib/mlbackend/python/classes/processor.php +++ b/lib/mlbackend/python/classes/processor.php @@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die(); * @copyright 2016 David Monllao {@link http://www.davidmonllao.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class processor implements \core_analytics\predictor { +class processor implements \core_analytics\classifier, \core_analytics\regressor { /** * The required version of the python package that performs all calculations.