← 返回题库
中级

对比全特征和去除WOE特征的AUC

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    loans_featured_csv = open_url(____).read()
    import pandas as pd
    from sklearn.ensemble import RandomForestClassifier
    from sklearn.model_selection import train_test_split
    from sklearn.metrics import roc_auc_score
    from io import StringIO
    df = pd.read_csv(StringIO(____))
    all_num=[c for c in df.select_dtypes(____).columns if c not in ['____','____'] and not c.endswith(____)]
    no_woe=[c for c in all_num if not c.endswith(____)]
    y=df['____']
    for label,cols in [(____),(____)]:
        X=df[cols].fillna(____)
        X_tr,X_te,y_tr,y_te=train_test_split(____)
        rf=RandomForestClassifier(____)
        rf.fit(____)
        auc=roc_auc_score(y_te,rf.predict_proba(____)[:,____])
        print(____)

示例

输入
solve()
期望输出
全特征: 41个特征, AUC=0.6625
去WOE特征: 35个特征, AUC=0.6738
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码