KS循环
testks=pd.ExcelWriter('test1.xlsx')
columns_df=pd.DataFrame(mx2.columns)
for i,j in enumerate(mx2.columns):
result=toad.metrics.KS_bucket(mx[j],mx['target'],bucket=10,method='quantile').sort_index()
result.to_excel(testks,sheet_name='kskn',startrow=14*i+1,index=False)
testks.save()
testks.close()
分箱加结果
data_sd = ZT3
import pycard as pc
num_iv_woedf = pd.DataFrame()
clf = pc.NumBin()
for i in coll:
if data_sd[i].isnull().sum()/len(data_sd)<1:
clf.fit(data_sd[i] ,data_sd['dpd30+'])
num_iv_woedf = num_iv_woedf.append(clf.woe_df_)