1

我试图找出 sklearn 的梯度提升分类器如何从不同的估计器中进行预测。

我想将 sklearn 模型翻译成基础 python 来执行预测。我知道如何从模型中获取单个估计器,但我不知道如何从这些单个估计器分数中得到集成模型做出的最终概率预测。我相信有一个 sigmoid 函数或其他东西,但我不知道是什么。

GBC = GradientBoostingClassifier(n_estimators=1)
GBC.fit(x_train, y_train, sample_weight=None)
GBC.predict_proba(np.array(x_test.iloc[0]).reshape(1,-1))

这将返回概率:array([[0.23084247, 0.76915753]]) 但是当我运行时:

Sole_estimator = GBC.estimators_[0][0]
Sole_estimator.predict(np.array(x_test.iloc[0]).reshape(1,-1)) 

它返回array([1.34327168]) 将 scipy 的 expit 应用于输出

expit(Sole_estimator.predict(np.array(x_test.iloc[0]).reshape(1,-1)))

我得到:

array([0.79302745])

我相信.init_估计器有助于预测,但还没有发现如何。我也将不胜感激有关如何使用 > 1 n_estimators 进行预测的任何迹象 - 如果它有所不同。

谢谢 :)

4

0 回答 0