def cnt_fea(data,feature,train_num):
data['flag'] = '-'
for fea in feature:
print(fea)
data[fea] = data[fea].map(data[fea].value_counts())
for i in range(len(feature)-1):
for j in range(i+1,len(feature)):
col = [feature[i],feature[j],'cnt']
print(col)
data['temp'] = data[feature[i]].astype(str) + data['flag'] + data[feature[j]].astype(str)
data['_'.join(col)] = data['temp'].map(data['temp'].value_counts())
del data['flag']
train = data.iloc[:train_num]
test = data.iloc[train_num:].reset_index(drop=True)
return train,test这里插入代码片
数据挖掘-统计特征
最新推荐文章于 2022-05-01 19:02:29 发布