1. 之前数据分析时发现,key4,5,7,8,9的取值差别对target的影响不大,于是删除这些特征,降低过拟合的风险。
clf = DecisionTreeClassifier()
clf.fit(
train_data.drop(['udmap', 'common_ts', 'uuid', 'target','key4','key5','key7','key8','key9'], axis=1),
train_data['target']
)
pd.DataFrame({
'uuid': test_data['uuid'],
'target': clf.predict(test_data.drop(['udmap', 'common_ts', 'uuid','key4','key5','key7','key8','key9'], axis=1))
}).to_csv('submit.csv', index=None)
线上提交分数提高0.00175
2.根据特征重要性,增加时间和x5的相关特征
train_data['common_ts_day'] = train_data['common_ts'].dt.day.astype(np.float32)
test_data['common_ts_day'] = test_data['common_ts'].dt.day.astype(np.float32)
train_data['common_ts_minute'] = train_data['common_ts'].dt.minute
test_data['common_ts_minute'] = test_data['common_ts'].dt.minute
train_data['common_ts_second'] = train_data['common_ts'].dt.second
test_data['common_ts_second'] = test_data['common_ts'].dt.second
train_data['common_ts_dayofweek'] = train_data['common_ts'].dt.dayofweek
test_data['common_ts_dayofweek'] = test_data['common_ts'].dt.dayofweek
train_data['x5_freq'] = train_data['x5'].map(train_data['x5'].value_counts())
test_data['x5_freq'] = test_data['x5'].map(train_data['x5'].value_counts())
train_data['x5_mean'] = train_data['x5'].map(train_data.groupby('x5')['target'].mean())
test_data['x5_mean'] = test_data['x5'].map(train_data.groupby('x5')['target'].mean())
线上提交分数降了0.01
3.续2,意识到分秒太浮夸,不符合实际,于是删除分秒特征,保留了星期,成绩提升了0.01