校准LightGBM或XGBoost的概率

我在校准LightGBM的概率时需要帮助

以下是我的代码

cv_results = lgb.cv(params,                     lgtrain,                     nfold=10,                    stratified=False ,                    num_boost_round = num_rounds,                    verbose_eval=10,                    early_stopping_rounds = 50,                     seed = 50)best_nrounds = cv_results.shape[0] - 1lgb_clf = lgb.train(params,                     lgtrain,                     num_boost_round=10000 ,                    valid_sets=[lgtrain,lgvalid],                    early_stopping_rounds=50,                    verbose_eval=10)ypred = lgb_clf.predict(test, num_iteration=lgb_clf.best_iteration)

回答:

我不确定LightGBM的情况,但在XGBoost的情况下,如果你想校准概率,最好且可能唯一的方法是使用sklearn的CalibratedClassifierCV

你可以在这里找到它 – https://scikit-learn.org/stable/modules/generated/sklearn.calibration.CalibratedClassifierCV.html

这里唯一的注意事项是CalibratedClassifierCV只能接受sklearn的估计器作为输入,所以你可能需要使用XGBoost的sklearn封装器,而不是传统的XGBoost API的.train函数。

你可以在这里找到XGBoost的sklearn封装器 – https://xgboost.readthedocs.io/en/latest/python/python_api.html#xgboost.XGBClassifier

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注