def gen_features(train, y, test):
for c in ['active', 'alco', 'smoke']:
le = preprocessing.LabelEncoder()
le.fit(train[c].values.tolist() + test[c].values.tolist())
train[c] = le.transform(train[c])
test[c] = le.transform(test[c])
train['ap_dif'] = train.ap_hi - train.ap_lo
test['ap_dif'] = test.ap_hi - test.ap_lo
h = train['height'] / 100
train['BWI'] = train['weight'] / (h * h)
h = test['height'] / 100
test['BWI'] = test['weight'] / (h * h)
imp = preprocessing.Imputer()
train = imp.fit_transform(train)
test = imp.transform(test)
return train, y, test
评论列表
文章目录