self.assertEqual(len(set(out["extra"].values)), 4)
// single group under threshold
enc = encoders.CountEncoder(verbose=1, min_group_size=30)
enc.fit(X)
out = enc.transform(X_t)
self.assertEqual(len(set(out["extra"].values)), 4)
// multiple groups under threshold
enc = encoders.CountEncoder(verbose=1, min_group_size=35)
After Change
self.assertIn("B_nan", enc.mapping["none"])
self.assertTrue(np.isin([28, 25, 19], out["na_categorical"].unique()).all())
self.assertTrue(out["na_categorical"].unique().shape == (3,))
self.assertTrue(enc.mapping is not None)
self.assertIn(np.nan, enc.mapping["na_categorical"])
def test_count_min_group_size_dict(self):
Test the min_group_size dict on "none" and "na_categorical".