Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402]

(no description)

File Size: 990 lines (43 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 10 files
 analytics/tests/fixtures/test_indicator_null.php
 analytics/tests/fixtures/test_indicator_max.php
 analytics/tests/fixtures/test_indicator_random.php
 analytics/tests/fixtures/test_target_shortname.php
 analytics/tests/fixtures/test_target_shortname_multiclass.php
 analytics/tests/fixtures/test_indicator_min.php
 analytics/tests/fixtures/test_indicator_multiclass.php
 analytics/tests/fixtures/test_indicator_fullname.php
 analytics/tests/fixtures/test_static_target_shortname.php
 course/lib.php

Defines 1 class


Class: prediction_test  - X-Ref

Unit tests for evaluation, training and prediction.

NOTE: in order to execute this test using a separate server for the
python ML backend you need to define these variables in your config.php file:

define('TEST_MLBACKEND_PYTHON_HOST', '127.0.0.1');
define('TEST_MLBACKEND_PYTHON_PORT', 5000);
define('TEST_MLBACKEND_PYTHON_USERNAME', 'default');
define('TEST_MLBACKEND_PYTHON_PASSWORD', 'sshhhh');

tearDown()   X-Ref
Purge all the mlbackend outputs.

This is done automatically for mlbackends using the web server dataroot but
other mlbackends may store files elsewhere and these files need to be removed.

return: null

test_static_prediction()   X-Ref
test_static_prediction

return: void

test_model_contexts()   X-Ref
test_model_contexts


test_ml_training_and_prediction($timesplittingid, $predictedrangeindex, $nranges, $predictionsprocessorclass,$forcedconfig)   X-Ref
test_ml_training_and_prediction

param: string $timesplittingid
param: int $predictedrangeindex
param: int $nranges
param: string $predictionsprocessorclass
param: array $forcedconfig
return: void

provider_ml_training_and_prediction()   X-Ref
provider_ml_training_and_prediction

return: array

test_ml_export_import($predictionsprocessorclass, $forcedconfig)   X-Ref
test_ml_export_import

param: string $predictionsprocessorclass The class name
param: array $forcedconfig

provider_ml_processors()   X-Ref
provider_ml_processors

return: array

test_ml_classifiers_return($success, $nsamples, $classes, $predictionsprocessorclass, $forcedconfig)   X-Ref
Test the system classifiers returns.

This test checks that all mlbackend plugins in the system are able to return proper status codes
even under weird situations.

param: int $success
param: int $nsamples
param: int $classes
param: string $predictionsprocessorclass
param: array $forcedconfig
return: void

provider_ml_classifiers_return()   X-Ref
test_ml_classifiers_return provider

We can not be very specific here as test_ml_classifiers_return only checks that
mlbackend plugins behave and expected and control properly backend errors even
under weird situations.

return: array

test_ml_multi_classifier($timesplittingid, $predictionsprocessorclass, $forcedconfig)   X-Ref
Tests correct multi-classification.

param: string $timesplittingid
param: string $predictionsprocessorclass
param: array|null $forcedconfig

provider_test_multi_classifier()   X-Ref
Provider for the multi_classification test.

return: array

test_ml_evaluation_configuration($modelquality, $ncourses, $expected, $predictionsprocessorclass,$forcedconfig)   X-Ref
Basic test to check that prediction processors work as expected.

param: string $modelquality
param: int $ncourses
param: array $expected
param: string $predictionsprocessorclass
param: array $forcedconfig
return: void

test_ml_evaluation_trained_model($predictionsprocessorclass, $forcedconfig)   X-Ref
Tests the evaluation of already trained models.

param: string $predictionsprocessorclass
param: array $forcedconfig
return: null

test_read_indicator_calculations()   X-Ref
test_read_indicator_calculations

return: void

test_not_null_samples()   X-Ref
test_not_null_samples


provider_ml_test_evaluation_configuration()   X-Ref
provider_ml_test_evaluation_configuration

return: array

add_random_model()   X-Ref
add_random_model

return: \core_analytics\model

add_perfect_model($targetclass = 'test_target_shortname')   X-Ref
add_perfect_model

param: string $targetclass
return: \core_analytics\model

add_multiclass_model($targetclass = 'test_target_shortname_multiclass')   X-Ref
Generates model for multi-classification

param: string $targetclass
return: \core_analytics\model

generate_courses($ncourses, array $params = [])   X-Ref
Generates $ncourses courses

param: int $ncourses The number of courses to be generated.
param: array $params Course params
return: null

generate_courses_multiclass($ncourses, array $params = [])   X-Ref
Generates ncourses for multi-classification

param: int $ncourses The number of courses to be generated.
param: array $params Course params
return: null

set_forced_config($forcedconfig)   X-Ref
Forces some configuration values.

param: array $forcedconfig

is_predictions_processor_ready(string $predictionsprocessorclass)   X-Ref
Is the provided processor ready using the current configuration in the site?

param: string  $predictionsprocessorclass
return: \core_analytics\predictor

add_prediction_processors($cases)   X-Ref
add_prediction_processors

param: array $cases
return: array