项目背景
小学三年级的正转正续班率比其他年级的要低很多,我们想排查一下原因,方法如下:用xgb输出一下特征的重要度,选取一些排名比较靠前的特征,我们将该特征在训练集和测试集上的分布进行可视化。
可视化代码
# 只看三年级英语
train_df3 = train_df.loc[(train_df['grade']==13)&(train_df['subject']==1)]
pred_df3 = pred_df.loc[(pred_df['grade']==13)&(pred_df['subject']==1)]
print(train_df3.shape)
print(pred_df3.shape)
for col in [ col for col in cols if col not in ['user_id','clazz_number']] :
print(col,':')
f=plt.figure(figsize=(22,5))
f.add_subplot(1,3,1)
ax = sns.lineplot(data= train_df3.loc[train_df3['label']==0,col].value_counts())
ax.set_title('label=0, col={}'.format(col))
f.add_subplot(1,3,2)
ax = sns.lineplot(data= train_df3.loc[train_df3['label']==1,col].value_counts())
ax.set_title('label=1, col={}'.format(col))
f.add_subplot(1,3,3)
ax = sns.lineplot(data= pred_df3[col].value_counts())
ax.set_title('pred, col={}'.format(col))
发现特征异常的处理方法:
1.查看所有参与主表join的特征表的分区是否都有数据;
2.查看特征工程是否跟随业务变化而作出相关调整,例如疫情期间作业数量和学币发放数量会比往常多,这时我们需要统计发放学币总数取学币发放的比例。