如何使用记分卡建立信用评分

2024-04-28 08:35:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用一个库来计算分数。我正在使用xgboost分类器,但收到一条错误消息

AttributeError: 'XGBClassifier' object has no attribute 'coef_'

代码

XGB = XGBClassifier(n_estimators=100, n_jobs=6, verbose=1)
# List the default parameters.
print(XGB.get_xgb_params())

# Train and evaluate 
XGB.fit(xtrain, ytrain, eval_metric=['rmse'], eval_set=[((xtrain, ytrain)),(xtest, ytest)])

probs = XGB.predict_proba(xtest)
roc = roc_auc_score(y_true=ytest, y_score=probs[:, 1])
print("RF roc score: {}".format(roc))

kfold = model_selection.KFold(n_splits=10, shuffle=True, random_state=7)
modelCV = XGB
scoring = 'accuracy'
results = model_selection.cross_val_score(modelCV, xtrain, ytrain, cv=kfold, scoring=scoring)
print("10-fold cross validation average accuracy: {}".format(results.mean()))

# score ------
card = sc.scorecard(bins_adj, XGB, xtrain.columns)
# credit score
train_score = sc.scorecard_ply(df_train, card, print_step=0)
test_score = sc.scorecard_ply(df_test, card, print_step=0)

NB我正在使用xgboost版本0.80

我如何着手解决这个问题


Tags: evalcardscorescprintrocscoringxgboost