def cal_ks(df, col, target):
"""
df:数据集
col:输入的特征
target:好坏标记的字段名
return:
ks: KS值
precision:准确率
tpr:召回率
fpr:打扰率
"""
bad = df[target].sum()
good = df[target].count() - bad
value_list = list(df[col])
label_list = list(df[target])
value_count = df[col].nunique()
items = sorted(zip(value_list, label_list), key=lambda x: x[0])
value_bin =
【数据处理】python数据评估常用指标:ks、fpr、tpr
最新推荐文章于 2024-04-17 21:31:09 发布