Esempio n. 1
0
    def test_exception_in_window_generation(self):
        ff = data_generator.get_files(self.test_dataset,
                                      self.test_coordinate_file)[1]

        g = data_generator.get_win(ff[0], ff[1], ['target1'], 10, 1,
                                   'faulty_loc')

        self.assertIsNone(g)
Esempio n. 2
0
    def test_get_win_no_sensors(self):
        ff = data_generator.get_files(self.test_dataset,
                                      self.test_coordinate_file)[2]

        g = data_generator.get_win(ff[0], ff[1], ['missing'], 10, 1,
                                   self.gen_path)

        df = pd.read_csv(g)
        self.assertEqual(61, len(df.loc[0].tolist()))
Esempio n. 3
0
    def test_get_win_binary_mock_other_strides(self):
        ff = data_generator.get_files(self.test_dataset,
                                      self.test_coordinate_file)[1]

        g = data_generator.get_win(ff[0], ff[1], ['target1'], 3, 2,
                                   self.gen_path)

        df = pd.read_csv(g)

        self.assertEqual(49, df.shape[0])
        self.assertCountEqual([0] * 4, df['label'].values.tolist()[:4])
Esempio n. 4
0
    def test_get_win_binary_mock_stride_one(self):
        ff = data_generator.get_files(self.test_dataset,
                                      self.test_coordinate_file)[1]

        g = data_generator.get_win(ff[0], ff[1], ['target1'], 10, 1,
                                   self.gen_path)

        df = pd.read_csv(g)

        self.assertEqual(91, df.shape[0])
        self.assertCountEqual([0] * 11, df['label'].values.tolist()[:11])
        self.assertCountEqual([1] * 29, df['label'].values.tolist()[11:40])
        self.assertCountEqual([0] * 11, df['label'].values.tolist()[40:51])
        self.assertCountEqual([1] * 29, df['label'].values.tolist()[51:80])
        self.assertCountEqual([0] * 11, df['label'].values.tolist()[80:91])
Esempio n. 5
0
    def test_get_win_count(self):
        ff = data_generator.get_files(self.test_dataset,
                                      self.test_coordinate_file)[1]

        g = data_generator.get_win(ff[0], ff[1], ['target1'], 10, 1,
                                   self.gen_path)
        self.assertEqual(g, os.path.join(self.gen_path, 'ex1.0.mock.0.csv'))
        df = pd.read_csv(g)
        self.assertEqual(int(((100 - 10) / 1) + 1), df.shape[0])

        g = data_generator.get_win(ff[0], ff[1], ['target1'], 20, 1,
                                   self.gen_path)
        df = pd.read_csv(g)
        self.assertEqual(int(((100 - 20) / 1) + 1), df.shape[0])

        g = data_generator.get_win(ff[0], ff[1], ['target1'], 20, 5,
                                   self.gen_path)
        df = pd.read_csv(g)
        self.assertEqual(int(((100 - 20) / 5) + 1), df.shape[0])

        g = data_generator.get_win(ff[0], ff[1], ['target1'], 18, 7,
                                   self.gen_path)
        df = pd.read_csv(g)
        self.assertEqual(int(((100 - 18) / 7) + 1), df.shape[0])
Esempio n. 6
0
    def test_get_win_mock(self):
        ff = data_generator.get_files(self.test_dataset,
                                      self.test_coordinate_file)[1]

        g = data_generator.get_win(ff[0], ff[1], ['target1'], 10, 1,
                                   self.gen_path)

        df = pd.read_csv(g)

        self.assertEqual(10 * 6 + 1, df.shape[1])

        synth = df.values.tolist()
        tg = []

        for x in range(1, 7):
            tg += [x, x + 1] + [x] * 8

        tg.append(0)

        self.assertCountEqual(tg, synth[0])
Esempio n. 7
0
    def test_get_win_normalize_zscore(self):
        ff = data_generator.get_files(self.test_dataset,
                                      self.test_coordinate_file)[1]

        g = data_generator.get_win(ff[0],
                                   ff[1], ['target1'],
                                   10,
                                   1,
                                   self.gen_path,
                                   normalize='zscore')

        df = pd.read_csv(g)
        first_win = df.loc[0].tolist()

        tg = []

        for x in range(1, 7):
            tg += [-0.100503781525, 9.949874371] + [-0.100503781525] * 8
        tg.append(0.0)

        self.assertEqual(61, len(first_win))
        self.assertTrue(np.allclose(tg, first_win, rtol=1e-04, atol=1e-08))
Esempio n. 8
0
    def test_get_win_normalize_minmax(self):
        ff = data_generator.get_files(self.test_dataset,
                                      self.test_coordinate_file)[1]

        g = data_generator.get_win(ff[0],
                                   ff[1], ['target1'],
                                   10,
                                   1,
                                   self.gen_path,
                                   normalize='minmax')

        df = pd.read_csv(g)
        first_win = df.loc[0].tolist()
        tg = []

        for x in range(1, 7):
            tg += [0.0, 1.0] + [0.0] * 8

        tg.append(0)

        self.assertEqual(61, len(first_win))
        self.assertCountEqual(tg, first_win)
        self.assertEqual(0.0, first_win[0])
        self.assertEqual(1.0, first_win[1])