iT邦幫忙

0

[Python] label encode with mean

dic_dummy = {}

for col in qualitativecol:
data = pd.concat([dfTrain['SalePrice'], dfTrain[col]], axis=1)
dic_tmp =data.groupby(col).mean().to_dict()
dic_tmp[col] = dic_tmp.pop('SalePrice')
dic_dummy.update(dic_tmp)

all_data.replace(dic_dummy, inplace=True)
all_data.head()


尚未有邦友留言

立即登入留言