Example #1
0
 def test_fit_pytorchgan_continuous_no_transfromer(self):
     dpgan = PytorchDPSynthesizer(
         eps, PATECTGAN(epsilon=eps, batch_size=batch_size), None)
     pd_data_xy = pd.DataFrame(np_data_xy, columns=["x", "y"])
     try:
         dpgan.fit(pd_data_xy, categorical_columns=['x'])
     except ValueError:
         return
     raise AssertionError('PATECTGAN should have raised a ValueError')
Example #2
0
class TestPytorchDPSynthesizer_PATECTGAN:
    def setup(self):
        self.patectgan = PytorchDPSynthesizer(1.0, PATECTGAN(), None)

    def test_fit(self):
        self.patectgan.fit(
            df_non_continuous,
            categorical_columns=['sex', 'educ', 'race', 'married'])
        assert self.patectgan.gan._generator

    def test_sample(self):
        self.patectgan.fit(
            df_non_continuous,
            categorical_columns=['sex', 'educ', 'race', 'married'])
        sample_size = len(df)
        synth_data = self.patectgan.sample(sample_size)
        assert synth_data.shape == df_non_continuous.shape
Example #3
0
class TestDPGAN:
    def setup(self):
        self.pategan = PytorchDPSynthesizer(1.0, PATEGAN(1.0),
                                            GeneralTransformer())

    def test_fit(self):
        df_non_continuous = df[['sex', 'educ', 'race', 'married']]
        self.pategan.fit(
            df_non_continuous,
            categorical_columns=['sex', 'educ', 'race', 'married'])
        assert self.pategan.gan.generator

    def test_sample(self):
        df_non_continuous = df[['sex', 'educ', 'race', 'married']]
        self.pategan.fit(
            df_non_continuous,
            categorical_columns=['sex', 'educ', 'race', 'married'])
        sample_size = len(df_non_continuous)
        synth_data = self.pategan.sample(sample_size)
        assert synth_data.shape == df_non_continuous.shape
Example #4
0
class TestPytorchDPSynthesizer_DPCTGAN:
    def setup(self):
        self.dpctgan = PytorchDPSynthesizer(1.0, DPCTGAN(), None)

    def test_fit(self):
        df_non_continuous = df[['sex', 'educ', 'race', 'married']]
        self.dpctgan.fit(
            df_non_continuous,
            categorical_columns=['sex', 'educ', 'race', 'married'])
        assert self.dpctgan.gan._generator

    def test_sample(self):
        self.dpctgan.fit(
            df_non_continuous,
            categorical_columns=['sex', 'educ', 'race', 'married'])
        sample_size = len(df)
        synth_data = self.dpctgan.sample(sample_size)
        assert synth_data.shape == df_non_continuous.shape

    def test_fit_numpy(self):
        dpctgan = DPCTGAN(epsilon=1.0)
        dpctgan.train(nf_non_continuous, categorical_columns=[0, 1, 2, 3])
Example #5
0
class TestPytorchDPSynthesizer_DPGAN:
    def setup(self):
        self.dpgan = PytorchDPSynthesizer(1.0, DPGAN(), GeneralTransformer())

    def test_fit(self):
        self.dpgan.fit(df_non_continuous,
                       categorical_columns=['sex', 'educ', 'race', 'married'])
        assert self.dpgan.gan.generator

    def test_sample(self):
        self.dpgan.fit(df_non_continuous,
                       categorical_columns=['sex', 'educ', 'race', 'married'])
        sample_size = len(df_non_continuous)
        synth_data = self.dpgan.sample(sample_size)
        assert synth_data.shape == df_non_continuous.shape

    def test_fit_continuous(self):
        dpgan = DPGAN(epsilon=1.0)
        df_continuous = df[['age', 'educ', 'income']]
        dpgan.train(df_continuous)
        synth_data = dpgan.generate(len(df_continuous))
        assert synth_data.shape == df_continuous.shape
Example #6
0
 def QuailSynth(epsilon):
     return PytorchDPSynthesizer(epsilon=epsilon, preprocessor=None,
                     gan=PATECTGAN(loss='cross_entropy', batch_size=50, pac=1))
Example #7
0
 def setup(self):
     self.pategan = PytorchDPSynthesizer(1.0, PATEGAN(1.0),
                                         GeneralTransformer())
Example #8
0
 def setup(self):
     self.patectgan = PytorchDPSynthesizer(
         1.0, PATECTGAN(regularization='dragan'), None)
Example #9
0
 def setup(self):
     self.patectgan = PytorchDPSynthesizer(1.0, PATECTGAN(), None)
Example #10
0
 def setup(self):
     self.dpctgan = PytorchDPSynthesizer(1.0, DPCTGAN(), None)
Example #11
0
 def setup(self):
     self.dpgan = PytorchDPSynthesizer(1.0, DPGAN(), GeneralTransformer())