首页 > 解决方案 > 带有 Skear XGBoost 和 Sklearn 校准分类器 CV 的 TypeError

问题描述

我正在尝试校准 XGBClassifier 的输出概率。

我提供了示例代码,

x_train, x_test, y_train, y_test = train_test_split(x_var, y_var, test_size = 0.2, shuffle = False)
new_mod2 = xgb.XGBClassifier(scale_pos_weight = 1, eta = 0.3, nthread = 10, learning_rate = 0.05, max_depth = 2, n_estimators = 180, objective = 'binary:logistic' )  
calibrated = CalibratedClassifierCV( base_estimator = new_mod2,method = 'Isotonic', cv=3)
calibrated.fit(X = x_train, y = y_train)

但是在运行 calibrated.fit() 函数时,出现以下错误:

TypeError: predict_proba() got an unexpected keyword argument 'X'

我的理解是 calibratedclassifiercv 应该与 sklearn xgboost 包装器一起使用。

然而,校准后的分类器 cv 似乎将不正确的变量传递给 xgboost 的 predict_proba() 方法。

是否有任何原因可能会发生这种情况?

标签: scikit-learnxgboostcalibrationxgbclassifier

解决方案


推荐阅读