Пример #1
0
    def test_encoding(self):
        enc1 = R.EffectEncoder("Color", ["Red", "Blue"])
        enc2 = R.IdentityEncoder("Height")
        enc3 = R.InteractionEncoder(enc1, enc2)
        encoder = R.DatasetEncoder([enc1, enc2, enc3])

        sample_size = 1000
        data = pd.DataFrame({
            "Height":
            np.random.randn(sample_size),
            "Color":
            np.random.choice(["Red", "Blue"], sample_size)
        })
        enc = encoder.encode_dataset(data)
        self.assertEqual(sample_size, enc.shape[0])
        self.assertEqual(4, enc.shape[1])
        self.assertTrue(np.allclose(enc[:, 2], data.iloc[:, 0]))
Пример #2
0
 def test_init(self):
     enc1 = R.EffectEncoder("Color", ["Red", "Blue"])
     enc2 = R.IdentityEncoder("Height")
     enc3 = R.InteractionEncoder(enc1, enc2)
     d = R.DatasetEncoder([enc1, enc2, enc3])
     self.assertIsInstance(d, R.DatasetEncoder)