我不断收到此错误:
invalid value encountered in double_scalars: mcc = cov_ytyp / np.sqrt(cov_ytyt * cov_ypyp)
我在自定义计分器中实现它的方式有问题吗?
parameters_XG = {'n_estimators': np.arange(50, 500, 50),
'learning_rate':np.arange(0.1, 1.05, .05),
'colsample_bytree': np.arange(0.1, 1.05, .05),
'sub_sample': np.arange(0.5, 1.05, .05),
'min_child_weight': np.arange(1, 10),
'gamma': np.arange(0.1, 5, 0.2),
'max_depth': np.arange(1, 15),
'scale_pos_weight': np.arange(0.1, 1.0, .05)}
XG_model = XGBClassifier(booster = 'gbtree', random_state=2504, n_jobs = -1)
multi_score = {'neg_log_loss': 'neg_log_loss',
'precision': 'precision',
'recall': 'recall',
'F1_weighted': 'f1_weighted',
'ROC_AUC': 'roc_auc',
'Brier_score': 'brier_score_loss',
'MCC': make_scorer(matthews_corrcoef)}
search_XG = RandomizedSearchCV(XG_model, parameters_XG, scoring = multi_score,
n_jobs = -1, cv = cv_RSKFCV, n_iter = 200, refit = 'neg_log_loss',
random_state = 2504).fit(X_train, y_train)
编辑:
我理解它为什么会抛出警告/错误,但是我不明白为什么现在它根本不适合?我希望只有很多值是 inf/nan 但目前它会回溯到 random_state = 2504).fit(X_train, y_train)
如何解决这个问题?