def test_cross_column(self): desc = self.new_field_desc() nc = fc.NumericColumn(desc) hash_bucket_size = 1024 cc = fc.CrossColumn([nc, 'cross_feature_2'], hash_bucket_size) self.assertEqual(cc.num_class(), hash_bucket_size) descs = cc.get_field_desc() self.assertEqual(len(descs), 2) self.assertEqual(descs[0].to_json(), desc.to_json()) self.assertEqual(descs[1].name, 'cross_feature_2')
def test_cross_column(self): desc = self.new_field_desc() nc = fc.NumericColumn(desc) hash_bucket_size = 1024 cc = fc.CrossColumn([nc, 'cross_feature_2'], hash_bucket_size) self.assertEqual(cc.num_class(), hash_bucket_size) descs = cc.get_field_desc() self.assertEqual(len(descs), 2) self.assertEqual(descs[0].to_json(), desc.to_json()) self.assertEqual(descs[1].name, 'cross_feature_2') d = fc.FeatureColumn.to_dict(cc) self.assertEqual(d["type"], "CrossColumn") keys = d["keys"] self.assertEqual(len(keys), 2) self.assertEqual(keys[0]["type"], "NumericColumn") self.assertEqual(keys[0]["field_desc"], desc.to_dict()) self.assertEqual(keys[1], "cross_feature_2") self.assertEqual(d["hash_bucket_size"], hash_bucket_size) self.check_from_dict(cc)