2

我正在尝试使用 Tweedie 发行版运行 lightgbm。我相信这段代码应该足以解决问题:

lgb_train=lgb.Dataset(X_train,y_train,weight=W_train,categorical_feature=cat_features)
lgb_test=lgb.Dataset(X_test,y_test,weight=W_test,reference=lgb_train,categorical_feature=cat_features)

params = {
'boosting': 'gbdt',
'application': 'tweedie',
'metric': 'tweedie',
'tweedie_variance_power':1.5,
'num_leaves': 31,
'learning_rate': 0.05,
'feature_fraction': 1,
'bagging_fraction': 1,
'bagging_freq': 0,
'verbose': 1,
'early_stopping_round':5,
'num_iterations':1000
}

mod1=lgb.train(params,lgb_train,valid_sets=[lgb_test])

当使用应用程序和度量作为泊松时,这运行良好,但是使用 Tweedie 我得到了这个回溯:

LightGBMError: b'No object function provided'
---------------------------------------------------------------------------
LightGBMError                             Traceback (most recent call last)
<ipython-input-348-84061fea80fd> in <module>()
     18 }
     19 
---> 20 mod1=lgb.train(params,lgb_train,valid_sets=[lgb_test])
C:\Python\anaconda3\lib\site-packages\lightgbm\engine.py in train(params, train_set, num_boost_round, valid_sets, valid_names, fobj, feval, init_model, feature_name, categorical_feature, early_stopping_rounds, evals_result, verbose_eval, learning_rates, keep_training_booster, callbacks)
    197                                     evaluation_result_list=None))
    198 
--> 199         booster.update(fobj=fobj)
    200 
    201         evaluation_result_list = []
C:\Python\anaconda3\lib\site-packages\lightgbm\basic.py in update(self, train_set, fobj)
   1437             _safe_call(_LIB.LGBM_BoosterUpdateOneIter(
   1438                 self.handle,
-> 1439                 ctypes.byref(is_finished)))
   1440             self.__is_predicted_cur_iter = [False for _ in range_(self.__num_dataset)]
   1441             return is_finished.value == 1
C:\Python\anaconda3\lib\site-packages\lightgbm\basic.py in _safe_call(ret)
     46     """
     47     if ret != 0:
---> 48         raise LightGBMError(_LIB.LGBM_GetLastError())
     49 
     50 
LightGBMError: b'No object function provided'

我假设我错过了一个参数,但我很确定我已经在文档中引用了 Tweedie 的所有内容。

请问你能帮忙吗?

干杯

4

1 回答 1

0

这也让我感到困惑,但事实证明最近才添加了 Tweedie 支持。只需重建 lightgbm 并记住也要重新安装 python 包。在 Linux 上:

git clone --recursive https://github.com/Microsoft/LightGBM
cd LightGBM
mkdir build
cd build
cmake ..
make -j4
cd LightGBM/python-package
python setup.py install
于 2018-02-16T22:45:45.927 回答