예제 #1
0
 def test_both_directions_e_value_threshold_med_max(self):
     results = detect_ts(
         self.raw_data,
         max_anoms=0.02,
         direction='both',
         threshold="med_max",
         e_value=True)
     eq_(len(results['anoms'].columns), 3)
     eq_(len(results['anoms'].iloc[:, 1]), 4)
예제 #2
0
 def test_both_directions_with_plot(self):
     results = detect_ts(
         self.raw_data,
         max_anoms=0.02,
         direction='both',
         only_last='day',
         plot=False)
     eq_(len(results['anoms'].columns), 2)
     eq_(len(results['anoms'].iloc[:, 1]), 21)
예제 #3
0
 def test_both_directions_e_value_longterm(self):
     results = detect_ts(
         self.raw_data,
         max_anoms=0.02,
         direction='both',
         longterm=True,
         plot=False,
         e_value=True)
     eq_(len(results['anoms'].columns), 3)
     eq_(len(results['anoms'].iloc[:, 1]), 114)
예제 #4
0
    def test_handling_of_leading_trailing_nas(self):
        for i in list(range(10)) + [len(self.raw_data) - 1]:
            self.raw_data.set_value(i, 'count', np.nan)

        results = detect_ts(self.raw_data,
                            max_anoms=0.02,
                            direction='both',
                            plot=False)
        eq_(len(results['anoms'].columns), 2)
        eq_(len(results['anoms'].iloc[:, 1]), 114)
예제 #5
0
    def test_check_midnight_date_format(self):
        data = pd.read_csv(os.path.join(self.path,
                                        'midnight_test_data.csv'),
                           usecols=['date', 'value'])

        data.date = date_format(data.date, "%Y-%m-%d %H:%M:%S")
        results = detect_ts(data, max_anoms=0.2, threshold=None,
                            direction='both', plot=False,
                            only_last="day",
                            e_value=True)
        eq_(len(results['anoms'].anoms), len(results['anoms'].expected_value))
예제 #6
0
 def test_handling_of_middle_nas(self):
     self.raw_data.set_value(len(self.raw_data) / 2, 'count', np.nan)
     detect_ts(self.raw_data, max_anoms=0.02, direction='both')