Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
core_analytics\local\time_splitting\base Class Reference

Base time splitting method. More...

Inheritance diagram for core_analytics\local\time_splitting\base:
core\analytics\time_splitting\no_splitting core\analytics\time_splitting\single_range core_analytics\local\time_splitting\accumulative_parts core_analytics\local\time_splitting\after_start core_analytics\local\time_splitting\equal_parts core_analytics\local\time_splitting\periodic core\analytics\time_splitting\deciles_accum core\analytics\time_splitting\quarters_accum core\analytics\time_splitting\one_month_after_start core\analytics\time_splitting\one_week_after_start core\analytics\time_splitting\ten_percent_after_start core\analytics\time_splitting\deciles core\analytics\time_splitting\quarters core_analytics\local\time_splitting\past_periodic core_analytics\local\time_splitting\upcoming_periodic

Public Member Functions

 append_rangeindex ($sampleid, $rangeindex)
 Generates a unique sample id (sample in a range index). More...
 
 cache_indicator_calculations ()
 Whether to cache or not the indicator calculations. More...
 
 get_all_ranges ()
 Returns the ranges used by this time splitting method. More...
 
 get_analysable ()
 get_analysable More...
 
 get_distinct_ranges ()
 Returns the distinct range indexes in this time splitting method. More...
 
 get_id ()
 Returns the time splitting method id. More...
 
 get_most_recent_prediction_range ()
 Returns the most recent range that can be used to predict. More...
 
 get_range_by_index ($rangeindex)
 Returns range data by its index. More...
 
 get_training_ranges ()
 By default all ranges are for training. More...
 
 include_range_info_in_training_data ()
 Whether to include the range index in the training data or not. More...
 
 infer_sample_info ($uniquesampleid)
 Returns the sample id and the range index from a uniquesampleid. More...
 
 is_valid_analysable (\core_analytics\analysable $analysable)
 Returns whether the course can be processed by this time splitting method or not. More...
 
 ready_to_predict ($range)
 Should we predict this time range now? More...
 
 ready_to_train ($range)
 Should we use this time range for training? More...
 
 set_analysable (\core_analytics\analysable $analysable)
 Assigns the analysable and updates the time ranges according to the analysable start and end dates. More...
 
 set_modelid (int $modelid)
 Assigns the model id to this time-splitting method it case it needs it. More...
 
 valid_for_evaluation ()
 Is this method valid to evaluate prediction models? More...
 

Static Public Member Functions

static get_name ()
 Returns a lang_string object representing the name for the time splitting method. More...
 

Protected Member Functions

 define_ranges ()
 Define the time splitting methods ranges. More...
 
 validate_ranges ()
 Validates the time splitting method ranges. More...
 

Protected Attributes

core_analytics analysable $analysable
 
string $id
 
int $modelid
 The model id.
 
array $ranges = []
 

Detailed Description

Base time splitting method.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ append_rangeindex()

core_analytics\local\time_splitting\base::append_rangeindex (   $sampleid,
  $rangeindex 
)
final

Generates a unique sample id (sample in a range index).

Parameters
int$sampleid
int$rangeindex
Return values
string

◆ cache_indicator_calculations()

core_analytics\local\time_splitting\base::cache_indicator_calculations ( )

Whether to cache or not the indicator calculations.

Indicator calculations are stored to be reused across models. The calculations are indexed by the calculation start and end time, and these times depend on the time-splitting method. You should overwrite this method and return false if the time frames generated by your time-splitting method are unique and / or can hardly be reused by further models.

Return values
bool

Reimplemented in core_analytics\local\time_splitting\upcoming_periodic, and core_analytics\local\time_splitting\after_start.

◆ define_ranges()

core_analytics\local\time_splitting\base::define_ranges ( )
abstractprotected

Define the time splitting methods ranges.

'time' value defines when predictions are executed, their values will be compared with the current time in ready_to_predict. The ranges should be sorted by 'time' in ascending order.

Return values
array('start'=> time(), 'end' => time(), 'time' => time())

Reimplemented in core\analytics\time_splitting\single_range, core\analytics\time_splitting\no_splitting, core_analytics\local\time_splitting\periodic, core_analytics\local\time_splitting\equal_parts, core_analytics\local\time_splitting\after_start, and core_analytics\local\time_splitting\accumulative_parts.

◆ get_all_ranges()

core_analytics\local\time_splitting\base::get_all_ranges ( )

Returns the ranges used by this time splitting method.

Return values
array

◆ get_analysable()

core_analytics\local\time_splitting\base::get_analysable ( )

get_analysable

Return values
core_analytics

◆ get_distinct_ranges()

core_analytics\local\time_splitting\base::get_distinct_ranges ( )

Returns the distinct range indexes in this time splitting method.

Return values
int[]

◆ get_id()

core_analytics\local\time_splitting\base::get_id ( )

Returns the time splitting method id.

Return values
string

◆ get_most_recent_prediction_range()

core_analytics\local\time_splitting\base::get_most_recent_prediction_range ( )

Returns the most recent range that can be used to predict.

This method is only called when calculating predictions.

Return values
array

◆ get_name()

static core_analytics\local\time_splitting\base::get_name ( )
staticabstract

◆ get_range_by_index()

core_analytics\local\time_splitting\base::get_range_by_index (   $rangeindex)

Returns range data by its index.

Parameters
int$rangeindex
Return values
array|falseRange data or false if the index is not part of the existing ranges.

◆ get_training_ranges()

core_analytics\local\time_splitting\base::get_training_ranges ( )

By default all ranges are for training.

Return values
array

Reimplemented in core_analytics\local\time_splitting\periodic.

◆ include_range_info_in_training_data()

core_analytics\local\time_splitting\base::include_range_info_in_training_data ( )

Whether to include the range index in the training data or not.

By default, we consider that the different time ranges included in a time splitting method may not be compatible between them (i.e. the indicators calculated at the end of the course can easily differ from indicators calculated at the beginning of the course). So we include the range index as one of the variables that the machine learning backend uses to generate predictions.

If the indicators calculated using the different time ranges available in this time splitting method are comparable you can overwrite this method to return false.

Note that:

  • This is only relevant for models whose predictions are not based on assumptions (i.e. the ones using a machine learning backend to generate predictions).
  • The ranges can only be included in the training data when we know the final number of ranges the time splitting method will have. E.g. We can not know the final number of ranges of a 'daily' time splitting method as we will have one new range every day.
    Return values
    bool

Reimplemented in core_analytics\local\time_splitting\periodic.

◆ infer_sample_info()

core_analytics\local\time_splitting\base::infer_sample_info (   $uniquesampleid)
final

Returns the sample id and the range index from a uniquesampleid.

Parameters
string$uniquesampleid
Return values
arrayarray($sampleid, $rangeindex)

◆ is_valid_analysable()

core_analytics\local\time_splitting\base::is_valid_analysable ( \core_analytics\analysable  $analysable)

Returns whether the course can be processed by this time splitting method or not.

Parameters
core_analytics\analysable$analysable
Return values
bool

Reimplemented in core_analytics\local\time_splitting\periodic, and core_analytics\local\time_splitting\after_start.

◆ ready_to_predict()

core_analytics\local\time_splitting\base::ready_to_predict (   $range)

Should we predict this time range now?

Parameters
array$range
Return values
bool

Reimplemented in core\analytics\time_splitting\no_splitting.

◆ ready_to_train()

core_analytics\local\time_splitting\base::ready_to_train (   $range)

Should we use this time range for training?

Parameters
array$range
Return values
bool

◆ set_analysable()

core_analytics\local\time_splitting\base::set_analysable ( \core_analytics\analysable  $analysable)

Assigns the analysable and updates the time ranges according to the analysable start and end dates.

Parameters
core_analytics\analysable$analysable
Return values
void

◆ set_modelid()

core_analytics\local\time_splitting\base::set_modelid ( int  $modelid)

Assigns the model id to this time-splitting method it case it needs it.

Parameters
int$modelid

◆ valid_for_evaluation()

core_analytics\local\time_splitting\base::valid_for_evaluation ( )

Is this method valid to evaluate prediction models?

Return values
bool

Reimplemented in core_analytics\local\time_splitting\upcoming_periodic.

◆ validate_ranges()

core_analytics\local\time_splitting\base::validate_ranges ( )
protected

Validates the time splitting method ranges.

Exceptions
coding_exception
Return values
void

The documentation for this class was generated from the following file: