简体   繁体   English

sklearn Forecast_proba没有Macthing类标签

[英]sklearn predict_proba not macthing class labels

I have trained a RandomForestClassifier on my dataset to predict 8 different topics from a body of text. 我已经在我的数据集中训练了一个RandomForestClassifier来从文本主体中预测8个不同的主题。 The dataset looks as follows for a given example 给定示例的数据集如下所示

X_train = [[0,0,0,0,0,1,0,0,1,0],
           [0,1,0,0,0,0,0,0,0,1],
           [1,0,0,0,0,0,0,0,0,1]]
          # This is a bag of word

y_train = ["A", "B", "C"] 
# 8 categories in total

If I run the following code 如果我运行以下代码

rdf = RandomForestClassifier(n_estimators = 100)
rdf_fitted = rdf.fit(X_train, y_train)
print rdf_fitted.predict(x_test[0])
print rdf_fitted.predict_proba(x_test[0])
print rdf_fitted.classes_

I get a strange result 我得到一个奇怪的结果

["B"]
[0.7, 0.2, 0.1]
["A","B","C"...]

Basically, the predicted label ("B" in this case) does not match the predict_proba predictions which suggests that "A" has the highest probability. 基本上,预测标签(在这种情况下为“ B”)与predict_proba预测不匹配,这表明“ A”具有最高的概率。

Any ideas what's causing this? 任何想法是什么原因造成的?

此问题是由于我在Jupyter Notebook安装程序中遇到的错误引起的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM