Exemplo n.º 1
0
    def local_error_calculation_test(self):
        """Testing the mean absolute error calculation of the MASE."""
        dataOrg = [[1.0, 10], [2.0, 12], [3.0, 14], [4.0, 13], [5.0, 17], [6.0, 20], [7.0, 23], [8.0, 26], [9.0, 29], [10.0, 31], [11.0, 26], [12.0, 21], [13.0, 18], [14.0, 14], [15.0, 13], [16.0, 19], [17.0, 24], [18.0, 28], [19.0, 30], [20.0, 32]]
        dataFor = [[1.0, 11], [2.0, 13], [3.0, 14], [4.0, 11], [5.0, 13], [6.0, 18], [7.0, 20], [8.0, 26], [9.0, 21], [10.0, 34], [11.0, 23], [12.0, 23], [13.0, 15], [14.0, 12], [15.0, 14], [16.0, 17], [17.0, 25], [18.0, 22], [19.0, 14], [20.0, 30]]

        historyLength = 5
        em = MeanAbsoluteScaledError(historyLength=historyLength)

        # A history length of 5 implies that the first 6 values have to be ignored for error calculation
        historyLength += 1
        dataOrg = dataOrg[historyLength:]
        dataFor = dataFor[historyLength:]

        for orgValue, forValue in zip(dataOrg, dataFor):
            difference = orgValue[1] - forValue[1]
            difference = abs(difference)

            assert difference == em.local_error([orgValue[1]], [forValue[1]])
Exemplo n.º 2
0
    def local_error_calculation_test(self):
        """Testing the mean absolute error calculation of the MASE."""
        dataOrg = [[1.0, 10], [2.0, 12], [3.0, 14], [4.0, 13], [5.0, 17], [6.0, 20], [7.0, 23], [8.0, 26], [9.0, 29], [10.0, 31], [11.0, 26], [12.0, 21], [13.0, 18], [14.0, 14], [15.0, 13], [16.0, 19], [17.0, 24], [18.0, 28], [19.0, 30], [20.0, 32]]
        dataFor = [[1.0, 11], [2.0, 13], [3.0, 14], [4.0, 11], [5.0, 13], [6.0, 18], [7.0, 20], [8.0, 26], [9.0, 21], [10.0, 34], [11.0, 23], [12.0, 23], [13.0, 15], [14.0, 12], [15.0, 14], [16.0, 17], [17.0, 25], [18.0, 22], [19.0, 14], [20.0, 30]]

        historyLength = 5
        em = MeanAbsoluteScaledError(historyLength=historyLength)

        # A history length of 5 implies that the first 6 values have to be ignored for error calculation
        historyLength += 1
        dataOrg = dataOrg[historyLength:]
        dataFor = dataFor[historyLength:]

        for orgValue, forValue in zip(dataOrg, dataFor):
            difference = orgValue[1] - forValue[1]
            difference = abs(difference)

            assert difference == em.local_error([orgValue[1]], [forValue[1]])