BaseErrorMeasure

class pycast.errors.baseerrormeasure.BaseErrorMeasure(minimalErrorCalculationPercentage=60)[source]

Bases: pycast.common.pycastobject.PyCastObject

Baseclass for all error measures.

__init__(minimalErrorCalculationPercentage=60)[source]

Initializes the error measure.

Parameters:minimalErrorCalculationPercentage (integer) – The number of entries in an original TimeSeries that have to have corresponding partners in the calculated TimeSeries. Corresponding partners have the same time stamp. Valid values are in [0.0, 100.0].
Raise:Raises a ValueError if minimalErrorCalculationPercentage is not in [0.0, 100.0].
_calculate(startingPercentage, endPercentage, startDate, endDate)[source]

This is the error calculation function that gets called by BaseErrorMeasure.get_error().

Both parameters will be correct at this time.

Parameters:
  • startingPercentage (float) – Defines the start of the interval. This has to be a value in [0.0, 100.0]. It represents the value, where the error calculation should be started. 25.0 for example means that the first 25% of all calculated errors will be ignored.
  • endPercentage (float) – Defines the end of the interval. This has to be a value in [0.0, 100.0]. It represents the value, after which all error values will be ignored. 90.0 for example means that the last 10% of all local errors will be ignored.
  • startDate (float) – Epoch representing the start date used for error calculation.
  • endDate (float) – Epoch representing the end date used in the error calculation.
Returns:

Returns a float representing the error.

Return type:

float

Raise:

Raises a NotImplementedError if the child class does not overwrite this method.

_get_error_values(startingPercentage, endPercentage, startDate, endDate)[source]

Gets the defined subset of self._errorValues.

Both parameters will be correct at this time.

Parameters:
  • startingPercentage (float) – Defines the start of the interval. This has to be a value in [0.0, 100.0]. It represents the value, where the error calculation should be started. 25.0 for example means that the first 25% of all calculated errors will be ignored.
  • endPercentage (float) – Defines the end of the interval. This has to be a value in [0.0, 100.0]. It represents the value, after which all error values will be ignored. 90.0 for example means that the last 10% of all local errors will be ignored.
  • startDate (float) – Epoch representing the start date used for error calculation.
  • endDate (float) – Epoch representing the end date used in the error calculation.
Returns:

Returns a list with the defined error values.

Return type:

list

Raise:

Raises a ValueError if startDate or endDate do not represent correct boundaries for error calculation.

confidence_interval(confidenceLevel)[source]

Calculates for which value confidenceLevel% of the errors are closer to 0.

Parameters:confidenceLevel (float) – percentage of the errors that should be smaller than the returned value for overestimations and larger than the returned value for underestimations. confidenceLevel has to be in [0.0, 1.0]
Returns:return a tuple containing the underestimation and overestimation for the given confidenceLevel
Return type:tuple
Warning:Index is still not calculated correctly
get_error(startingPercentage=0.0, endPercentage=100.0, startDate=None, endDate=None)[source]

Calculates the error for the given interval (startingPercentage, endPercentage) between the TimeSeries given during BaseErrorMeasure.initialize().

Parameters:
  • startingPercentage (float) – Defines the start of the interval. This has to be a value in [0.0, 100.0]. It represents the value, where the error calculation should be started. 25.0 for example means that the first 25% of all calculated errors will be ignored.
  • endPercentage (float) – Defines the end of the interval. This has to be a value in [0.0, 100.0]. It represents the value, after which all error values will be ignored. 90.0 for example means that the last 10% of all local errors will be ignored.
  • startDate (float) – Epoch representing the start date used for error calculation.
  • endDate (float) – Epoch representing the end date used in the error calculation.
Returns:

Returns a float representing the error.

Return type:

float

Raise:

Raises a ValueError in one of the following cases:

  • startingPercentage not in [0.0, 100.0]
  • endPercentage not in [0.0, 100.0]
  • endPercentage < startingPercentage
Raise:

Raises a StandardError if BaseErrorMeasure.initialize() was not successfull before.

initialize(*args, **kwargs)[source]

Initializes the ErrorMeasure.

During initialization, all BaseErrorMeasure.local_errors() are calculated.

Parameters:
  • originalTimeSeries (TimeSeries) – TimeSeries containing the original data.
  • calculatedTimeSeries (TimeSeries) – TimeSeries containing calculated data. Calculated data is smoothed or forecasted data.
Returns:

Return True if the error could be calculated, False otherwise based on the minimalErrorCalculationPercentage.

Return type:

boolean

Raise:

Raises a StandardError if the error measure is initialized multiple times.

local_error(originalValue, calculatedValue)[source]

Calculates the error between the two given values.

Parameters:
  • originalValue (list) – List containing the values of the original data.
  • calculatedValue (list) – List containing the values of the calculated TimeSeries that corresponds to originalValue.
Returns:

Returns the error measure of the two given values.

Return type:

numeric

Raise:

Raises a NotImplementedError if the child class does not overwrite this method.

Previous topic

Error Measures

Next topic

Mean Squared Error

This Page