Example #1
0
    def error_calculation_test(self):
        """Test the calculation of the SymmetricMeanAbsolutePercentageError."""
        dataPtsOrg = [
            2.30, .373, .583, 1.88, 1.44, -0.0852, -.341, .619, .131, 1.27, 0
        ]
        dataPtsCalc = [
            -1.21, -.445, .466, .226, -.694, -.575, 2.73, -1.49, -1.45, -.193,
            0
        ]

        tsOrg = TimeSeries()
        tsCalc = TimeSeries()

        for idx in xrange(len(dataPtsOrg)):
            tsOrg.add_entry(float(idx), dataPtsOrg[idx])
            tsCalc.add_entry(float(idx), dataPtsCalc[idx])

        smape = SymmetricMeanAbsolutePercentageError()
        smape.initialize(tsOrg, tsCalc)

        ## compare the strings due to accuracy
        assert "1.5706" == str(smape.get_error())[:6]
Example #2
0
    def local_error_test(self):
        """Test SymmetricMeanAbsolutePercentageError local error."""
        dataPtsOrg = [
            2.30, .373, .583, 1.88, 1.44, -0.0852, -.341, .619, .131, 1.27, 4.0
        ]
        dataPtsCalc = [
            -1.21, -.445, .466, .226, -.694, -.575, 2.73, -1.49, -1.45, -.193,
            4.0
        ]
        localErrors = [
            2.0, 2.0, 0.223069590086, 1.57075023742, 2.0, 1.48379279006, 2.0,
            2.0, 2.0, 2.0, 0.0
        ]

        smape = SymmetricMeanAbsolutePercentageError()

        for idx in xrange(len(dataPtsOrg)):
            le = smape.local_error([dataPtsOrg[idx]], [dataPtsCalc[idx]])
            ple = localErrors[idx]

            ## compare the strings due to accuracy
            assert str(le) == str(ple)