Errors

Types of error response of a percectual control hierarchy.
The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload
from unittest import TestCase

ErrorResponse - aggregation

BaseErrorType


source

BaseErrorType

 BaseErrorType (flip_error_response=False)

Base class of a type error response. This class is not used direclty by developers, but defines the interface common to all.

RootSumSquaredError


source

RootSumSquaredError

 RootSumSquaredError (flip_error_response=False)

The square root of the sum of the square of the errors.

RootMeanSquareError


source

RootMeanSquareError

 RootMeanSquareError (flip_error_response=False)

The square root of the mean of the sum of the square of the errors.

SummedError


source

SummedError

 SummedError (flip_error_response=False)

Sum of all errors.

CurrentError


source

CurrentError

 CurrentError (flip_error_response=False)

The current error, rather than a function of the historical values.

CurrentRMSError


source

CurrentRMSError

 CurrentRMSError (flip_error_response=False)

The current RMS error, rather than a function of the historical values.

SmoothError


source

SmoothError

 SmoothError (flip_error_response=False)

The exponential smoothed value of the error.

MovingSumError


source

MovingSumError

 MovingSumError (flip_error_response=False)

The moving sum of the error.

MovingAverageError


source

MovingAverageError

 MovingAverageError (flip_error_response=False)

The moving average of the error.

ErrorResponseFactory


source

ErrorResponseFactory

 ErrorResponseFactory ()

Initialize self. See help(type(self)) for accurate signature.

Error collection - from each iteration

ErrorCollectorFactory


source

ErrorCollectorFactory

 ErrorCollectorFactory ()

Initialize self. See help(type(self)) for accurate signature.

BaseErrorCollector


source

BaseErrorCollector

 BaseErrorCollector (limit, error_response, min=True)

Base class of an error collector. This class is not used direclty by developers, but defines the interface common to all.

TotalError


source

TotalError

 TotalError (limit=None, error_response=None, min=None, **cargs)

A class to collect all the errors of the control system run.

TopError


source

TopError

 TopError (limit=None, error_response=None, min=None, **cargs)

A class to collect all the errors of the top-level nodes.

InputsError


source

InputsError

 InputsError (limit=None, error_response=None, min=None, **cargs)

A class to collect the values of the input values.

ReferencedInputsError


source

ReferencedInputsError

 ReferencedInputsError (limit=None, error_response=None, min=None,
                        **cargs)

A class to collect the values of the input values subtracted from reference values.

RewardError


source

RewardError

 RewardError (limit=None, error_response=None, min=None, **cargs)

A class that collects the reward value of the control system run.

FitnessError


source

FitnessError

 FitnessError (limit=None, error_response=None, min=None, **cargs)

A class that collects the fitness value of the control system run.

Examples

rms = RootMeanSquareError()
for i in range(10):
    rms([i])
er = rms.get_error_response()
print(er)
TestCase().assertAlmostEqual(er, 5.338539126015656, places=6)
5.338539126015656
rsse = RootSumSquaredError()
te = TotalError(error_response=rsse, limit=250,min=True)   
te.add_error_data([1, 2])
print(te)
err=te.error()
print(err)
TestCase().assertAlmostEqual(err, 2.23606797749979, places=6)
TotalError limit:250, limit_exceeded:False, : RootSumSquaredError error_response:2.23606797749979
2.23606797749979
et = ErrorResponseFactory.createErrorResponse('RootSumSquaredError')   
et(102)
print(et.get_error_response())

iprms = ErrorCollectorFactory.createErrorCollector('TotalError')   
iprms.set_limit(100)
iprms.set_error_response(et)
print(iprms.error())
102.0
102.0
iprms = BaseErrorCollector.collector( 'RootMeanSquareError','InputsError', 10, flip_error_response=False, min=False)
time_series_example = np.array([[1, 2, 3],
                                [4, 5, 6],
                                [7, 8, 9],
                                [10, 11, 12],
                                [13, 14, 15]])
for ts in time_series_example:
    iprms.add_error_data(ts)
erms = iprms.error()
print(erms)
print(iprms)
TestCase().assertAlmostEqual(erms, 9.092121131323903, places=6)
9.092121131323903
InputsError limit:10, limit_exceeded:False, : RootMeanSquareError error_response:9.092121131323903
iprms.reset()
print(iprms)
InputsError limit:10, limit_exceeded:False, : RootMeanSquareError error_response:None
iprms2 = BaseErrorCollector.collector( 'RootMeanSquareError','InputsError', 10, flip_error_response=False, min=False)
time_series_example2 = np.array([[1, 2, 3],
                                [4, 5, 6],
                                [7, 8, 9],
                                [10, 11, 12],
                                [13, 14, 15]])
for ts in time_series_example2:
    iprms2.add_error_data_array(ts)
erms2 = iprms2.error()
print(erms2)
print(iprms2)
TestCase().assertAlmostEqual(erms2, 15.748015748023622, places=6)
15.748015748023622
InputsError limit:10, limit_exceeded:False, : RootMeanSquareError error_response:15.748015748023622
iprms1 = BaseErrorCollector.collector( 'RootMeanSquareError','InputsError', 10, flip_error_response=False, min=False)
iprms1.add_error_data([3])
iprms1.add_error_data([5])
erms1 = iprms1.error()
print(erms1)
print(iprms1)
TestCase().assertAlmostEqual(erms1, 4.123105625617661, places=6)
4.123105625617661
InputsError limit:10, limit_exceeded:False, : RootMeanSquareError error_response:4.123105625617661
ip_curr_rms = BaseErrorCollector.collector( 'CurrentRMSError','InputsError', 10, flip_error_response=False, min=False)
data = [4, 5, 6]
ip_curr_rms.add_error_data_array(data)
rms = ip_curr_rms.error()
print(rms)
print(ip_curr_rms)
TestCase().assertAlmostEqual(rms, 5.066228051190222, places=6)
5.066228051190222
InputsError limit:10, limit_exceeded:False, : CurrentRMSError error_response:5.066228051190222
refins_rms = BaseErrorCollector.collector( 'RootMeanSquareError','ReferencedInputsError', 10, flip_error_response=False, min=False)
time_series1 = np.array([[1, 2, 3],
                                [4, 5, 6],
                                [7, 8, 9],
                                [10, 11, 12],
                                [13, 14, 15]])
for ts in time_series1:
    refins_rms.add_error_data_array(ts)
erms = refins_rms.error()
print(erms)
print(refins_rms)
TestCase().assertAlmostEqual(erms, 15.748015748023622, places=6)
15.748015748023622
ReferencedInputsError limit:10, limit_exceeded:False, : RootMeanSquareError error_response:15.748015748023622
ins_sm = BaseErrorCollector.collector( 'SmoothError','InputsError', 10, flip_error_response=False, min=False, properties={'error_response': {'smooth_factor': 0.9}})
time_series1 = np.array([[1, 2, 3],
                                [4, 5, 6],
                                [7, 8, 9],
                                [10, 11, 12],
                                [13, 14, 15]])
for ts in time_series1:
    ins_sm.add_error_data(ts)
ersm = ins_sm.error()
print(ersm)
print(ins_sm)
TestCase().assertAlmostEqual(ersm, 7.853020188851838, places=6)
7.853020188851838
InputsError limit:10, limit_exceeded:False, : SmoothError error_response:7.853020188851838
ins_sm1 = BaseErrorCollector.collector( 'SmoothError','InputsError', 10, flip_error_response=False, min=False, properties={'error_response': {'smooth_factor': 0.9}})
time_series1 = np.array([[1, 2, 3],
                                [4, 5, 6],
                                [7, 8, 9],
                                [10, 11, 12],
                                [13, 14, 15]])
for ts in time_series1:
    ins_sm1.add_error_data_array(ts)
ersm1 = ins_sm1.error()
print(ersm1)
print(ins_sm1)
TestCase().assertAlmostEqual(ersm1, 6.161823641446112, places=6)
6.161823641446112
InputsError limit:10, limit_exceeded:False, : SmoothError error_response:6.161823641446112
ins_sm2 = BaseErrorCollector.collector( 'SmoothError','InputsError', 10, flip_error_response=False, min=False, properties={'error_response': {'smooth_factor': 0.5}})
error_response = ins_sm2.get_error_response()
initial = 100
error_response.set_error_response(initial)
for i in range(5):
    ins_sm2.add_error_data_array([initial+i])
ersm1 = ins_sm2.error()
print(ersm1)
print(ins_sm2)
TestCase().assertAlmostEqual(ersm1, 103.0625, places=6)
103.0625
InputsError limit:10, limit_exceeded:False, : SmoothError error_response:103.0625
time_series1 = np.array([[1, 2, 3],
                                [4, 5, 6],
                                [7, 8, 9],
                                [10, 11, 12],
                                [13, 14, 15]])
norms = np.linalg.norm(time_series1, axis=1)
print(norms)
[ 3.74165739  8.77496439 13.92838828 19.10497317 24.2899156 ]