lbe = LabelEncoder()
data[feat] = lbe.fit_transform(data[feat])
// 2.count //unique features for each sparse field
sparse_feature_dim = {feat: data[feat].nunique()
for feat in sparse_features}
// 3.generate input data for model
train, test = train_test_split(data, test_size=0.2)
train_model_input = [train[feat].values for feat in sparse_feature_dim]
test_model_input = [test[feat].values for feat in sparse_feature_dim]
After Change
lbe = LabelEncoder()
data[feat] = lbe.fit_transform(data[feat])
// 2.count //unique features for each sparse field
sparse_feat_list = [SingleFeat(feat,data[feat].nunique()) for feat in sparse_features]
// 3.generate input data for model
train, test = train_test_split(data, test_size=0.2)
train_model_input = [train[feat.name].values for feat in sparse_feat_list]