def testModelRunsOnUCIData(self):
        model = utils.get_uci_model()
        model.compile(optimizer='adam', loss='binary_crossentropy')
        data = utils.get_uci_data()
        print('DATA:', data)
        dataset = utils.df_to_dataset(data, batch_size=64)

        # Model can train on UCI data
        model.fit(dataset, epochs=1)

        # Model can evaluate on UCI data
        model.evaluate(dataset)
    def testConvertToDataset(self):
        expected_vals = range(10)  # Arbitrary values
        expected_labels = [0, 0, 1, 0, 1, 1, 1, 1, 0, 0]  # Arbitrary labels.
        data = {
            'col': pd.Series(expected_vals),
            'target': pd.Series(expected_labels)
        }
        df = pd.DataFrame(data)
        dataset = utils.df_to_dataset(df)
        vals, labels = zip(*[(val, label.numpy()) for val, label in dataset])

        # Assert values are all dicts with exactly one column.
        for val in vals:
            self.assertSetEqual(set(val.keys()), set(['col']))
        vals = [val['col'].numpy() for val in vals]

        self.assertAllClose(vals, expected_vals)
        self.assertAllClose(labels, expected_labels)
    def testConvertToDatasetWithShuffle(self):
        expected_vals = range(10)  # Arbitrary values
        expected_labels = [0, 0, 1, 0, 1, 1, 1, 1, 0, 0]  # Arbitrary labels.
        data = {
            'col': pd.Series(expected_vals),
            'target': pd.Series(expected_labels)
        }
        df = pd.DataFrame(data)
        dataset = utils.df_to_dataset(df, shuffle=True)
        vals, labels = zip(*[(val, label.numpy()) for val, label in dataset])

        # Assert values are all dicts with exactly one column.
        for val in vals:
            self.assertSetEqual(set(val.keys()), set(['col']))
        vals = [val['col'].numpy() for val in vals]

        # These values should *NOT* be close because vals should be out of order
        # since we set shuffle=True. Note that it seems like the tests provide a
        # consistent seed so we don't have to worry about getting unlucky. If this
        # changes then we can look into explicitly setting the a seed.
        self.assertNotAllClose(vals, expected_vals)
        # Assert that the contents are the same, just reordered
        self.assertAllClose(sorted(vals), sorted(expected_vals))
        self.assertAllClose(sorted(labels), sorted(expected_labels))