def local_error_test(self): """Test MeanAbsoluteDeviationError.local_error.""" localErrors = [0.2, 0.3, 0.4, 0.5, 0.5, 0.3, 0.2, 0.6, 0.3, 0.5, 0] # dataPtsOrg = [ 2.30, .373, .583, 1.880, 500] # dataPtsCalc = [-1.21, -.445, .466, .226, 300] # localErrors = [ 3.51, .818, .117, 1.654, 200] mad = MeanAbsoluteDeviationError() for idx in xrange(len(self.dataOrg)): le = mad.local_error([self.dataOrg[idx]], [self.dataCalc[idx]]) ple = localErrors[idx] # compare the strings due to accuracy self.assertEqual(str(le), str(ple))
def error_calculation_test(self): """Test the calculation of the Mean Absolute Deviation Error.""" #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(self.dataOrg)): tsOrg.add_entry(float(idx), self.dataOrg[idx]) tsCalc.add_entry(float(idx), self.dataCalc[idx]) mad = MeanAbsoluteDeviationError() mad.initialize(tsOrg, tsCalc) # compare the strings due to accuracy self.assertEqual("0.3454", str(mad.get_error())[:6])