ValueError:TextPredictor应该是精度召回曲线的二进制分类器

2024-05-08 03:59:03 发布

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

我试图使用ktrain(BERT的包装器)绘制二进制文本分类的精确召回曲线,并得到以下错误

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-142-9069d96b6d6b> in <module>
----> 1 disp = plot_precision_recall_curve(predictor, df_testing.description.values, df_testing.pred_class)
      2 disp.ax_.set_title('2-class Precision-Recall curve: '
      3                    'AP={0:0.2f}'.format(average_precision))

C:\conda\lib\site-packages\sklearn\metrics\_plot\precision_recall_curve.py in plot_precision_recall_curve(estimator, X, y, sample_weight, response_method, name, ax, **kwargs)
    145         estimator.__class__.__name__))
    146     if not is_classifier(estimator):
--> 147         raise ValueError(classification_error)
    148 
    149     prediction_method = _check_classifer_response_method(estimator,

ValueError: TextPredictor should be a binary classifier

我的预测值是<ktrain.text.predictor.TextPredictor at 0x2d9361e61c8>。 有没有一种方法可以将预测器转换为二进制分类器


Tags: indfplot二进制testingpredictormethodclass