XGBoosError:参数num_class的值0应大于等于1 num_class:多类分类中输出类的数量

2024-09-25 00:27:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用XGBoost分类器进行多标签分类。我有7个标签,每个都是二进制的。在运行脚本时,在.fit()方法中,我得到以下错误:

    MultiLabelML_Estimator.fit(X_train, Y_train_Temp)

  File "c:\users\ankush\anaconda3\lib\site-packages\skmultilearn\problem_transform\br.py", line 161, in fit
    classifier.fit(self._ensure_input_format(

  File "c:\users\ankush\anaconda3\lib\site-packages\xgboost\sklearn.py", line 828, in fit
    self._Booster = train(xgb_options, train_dmatrix,

  File "c:\users\ankush\anaconda3\lib\site-packages\xgboost\training.py", line 208, in train
    return _train_internal(params, dtrain,

  File "c:\users\ankush\anaconda3\lib\site-packages\xgboost\training.py", line 75, in _train_internal
    bst.update(dtrain, i, obj)

  File "c:\users\ankush\anaconda3\lib\site-packages\xgboost\core.py", line 1159, in update
    _check_call(_LIB.XGBoosterUpdateOneIter(self.handle,

  File "c:\users\ankush\anaconda3\lib\site-packages\xgboost\core.py", line 188, in _check_call
    raise XGBoostError(py_str(_LIB.XGBGetLastError()))

XGBoostError: value 0 for Parameter num_class should be greater equal to 1
num_class: Number of output class in the multi-class classification.

    [... skipped 1 hidden frame]

我在互联网上搜索了很多资料,比如https://stackoverflow.com/questions/62225734/xgboosterror-value-0-for-parameter-num-class-should-be-greater-equal-to-1,但没有找到任何合适的解决方案

有人知道这件事吗


Tags: inpyselflibpackageslinesitetrain