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\time_splitting\past_week Class Reference

Time splitting method that generates weekly predictions. More...

Inheritance diagram for core\analytics\time_splitting\past_week:
core_analytics\local\time_splitting\past_periodic core_analytics\local\time_splitting\periodic core_analytics\local\time_splitting\before_now core_analytics\local\time_splitting\base

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 ()
 Overwritting as the last range may be for prediction. More...
 
 include_range_info_in_training_data ()
 Overwritten as all generated rows are comparable. 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 analysable can be processed by this time splitting method or not. More...
 
 periodicity ()
 Once per week. 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 ()
 The time splitting method name. More...
 

Protected Member Functions

 define_ranges ()
 define_ranges More...
 
 get_first_start ()
 Get the start of the first time range. More...
 
 get_next_range (\DateTimeImmutable $time)
 Gets the next range with start on the provided time. More...
 
 update_last_range (array $ranges)
 Guarantees that the last range dates end right now. 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

Time splitting method that generates weekly predictions.

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 
)
finalinherited

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 ( )
inherited

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\periodic::define_ranges ( )
protectedinherited

define_ranges

Return values
array

Reimplemented from core_analytics\local\time_splitting\base.

◆ get_all_ranges()

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

Returns the ranges used by this time splitting method.

Return values
array

◆ get_analysable()

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

get_analysable

Return values
core_analytics

◆ get_distinct_ranges()

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

Returns the distinct range indexes in this time splitting method.

Return values
int[]

◆ get_first_start()

core_analytics\local\time_splitting\past_periodic::get_first_start ( )
protectedinherited

Get the start of the first time range.

Return values
intA timestamp.

Reimplemented from core_analytics\local\time_splitting\periodic.

◆ get_id()

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

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 ( )
inherited

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\time_splitting\past_week::get_name ( )
static

The time splitting method name.

Return values
lang_string

Reimplemented from core_analytics\local\time_splitting\base.

◆ get_next_range()

core_analytics\local\time_splitting\past_periodic::get_next_range ( \DateTimeImmutable  $time)
protectedinherited

Gets the next range with start on the provided time.

The next range is based on the past period so we substract this range's periodicity from $time.

Parameters
DateTimeImmutable$time
Return values
array

Reimplemented from core_analytics\local\time_splitting\periodic.

◆ get_range_by_index()

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

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\periodic::get_training_ranges ( )
inherited

Overwritting as the last range may be for prediction.

Return values
array

Reimplemented from core_analytics\local\time_splitting\base.

◆ include_range_info_in_training_data()

core_analytics\local\time_splitting\periodic::include_range_info_in_training_data ( )
inherited

Overwritten as all generated rows are comparable.

Return values
bool

Reimplemented from core_analytics\local\time_splitting\base.

◆ infer_sample_info()

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

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\periodic::is_valid_analysable ( \core_analytics\analysable  $analysable)
inherited

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

Parameters
core_analytics\analysable$analysable
Return values
bool

Reimplemented from core_analytics\local\time_splitting\base.

◆ periodicity()

core\analytics\time_splitting\past_week::periodicity ( )

Once per week.

Return values
DateInterval

Reimplemented from core_analytics\local\time_splitting\periodic.

◆ ready_to_predict()

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

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)
inherited

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)
inherited

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)
inherited

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

Parameters
int$modelid

◆ update_last_range()

core_analytics\local\time_splitting\past_periodic::update_last_range ( array  $ranges)
protectedinherited

Guarantees that the last range dates end right now.

Parameters
array$ranges
Return values
array

Reimplemented from core_analytics\local\time_splitting\periodic.

◆ valid_for_evaluation()

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

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 ( )
protectedinherited

Validates the time splitting method ranges.

Exceptions
coding_exception
Return values
void

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