我用了逻辑回归与AutoGluon两个方法构架评分卡,按理说AutoGluon构建的模型roc_auc要更好啊,但是结果确是,他俩输出的结果一模一样,为什么会一模一样啊?
Xtr_woe = data_tr_woe.drop(['isDefault','type'],axis=1)
Ytr_woe = data_tr_woe['isDefault']
Xts_woe = data_ts_woe.drop(['isDefault','type'],axis=1)
Yts_woe = data_ts_woe['isDefault']
from sklearn.linear_model import LogisticRegression
lr = LogisticRegression()
lr.fit(Xtr_woe,Ytr_woe)
from toad.metrics import KS, F1, AUC
EYtr_proba = lr.predict_proba(Xtr_woe)[:,1]
EYtr = lr.predict(Xtr_woe)
print('Training error')
print('KS:', KS(EYtr_proba,Ytr_woe))
print('AUC:', AUC(EYtr_proba,Ytr_woe))
EYts_proba = lr.predict_proba(Xts_woe)[:,1]
EYts = lr.predict(Xts_woe)
print('\nTest error')
print('KS:', KS(EYts_proba,Yts_woe))
print('AUC:', AUC(EYts_proba,Yts_woe))
这是逻辑回归的代码,我一个参数都没调
import autogluon
from autogluon.tabular import TabularDataset,TabularPredictor
import pandas as pd
import numpy as np
label='isDefault'
train_data=TabularDataset(data_tr_woe.drop(["type"],axis=1) )
metric = 'roc_auc'
predictor=TabularPredictor(label=label,eval_metric=metric).fit(train_data,presets='best_quality')
best=predictor.get_model_best()
print(best)
test_data=TabularDataset(data_ts_woe.drop(['isDefault','type'],axis=1))
auto_proba=predictor.predict_proba(test_data)
auto_proba = np.array(EYts_proba).flatten()
print(auto_proba )
print(len(auto_proba ))
print('\nTest error')
print('KS:', KS(auto_proba,Yts_woe))
print('AUC:', AUC(auto_proba,Yts_woe))
这是auto的代码,他俩输出的proba一模一样,我要崩溃了