从带有多个类的RandomForest绘制数据的问题

时间:2019-05-12 07:21:36

标签: python matplotlib random-forest text-classification

因此,我正在使用文本分类对方言进行分类,并且需要绘制精度调用和ROC曲线,以下代码是绘图的初始设置,正如本文所回答的: How to plot precision and recall of multiclass classifier?

n_classes = len(set(all_data['dialect']))

Y = label_binarize(all_data['dialect'], classes=[*range(n_classes)])

X_train, X_test, y_train, y_test = train_test_split(all_data['tweets'],Y,
                                                    random_state = 42)

clf = OneVsRestClassifier(RandomForestClassifier(n_estimators=50,
                             max_depth=3,
                             random_state=0))
clf.fit(X_train, y_train)

y_score = clf.predict_proba(X_test)

我收到这样的警告:

UserWarning: Label not 0 is present in all training examples.
UserWarning: Label not 1 is present in all training examples.
UserWarning: Label not 2 is present in all training examples.

当我继续用其余代码绘图时,图形为空。

0 个答案:

没有答案