1
对于我想检索给定样本的预测分数/概率的所有类。我正在使用sklearn的RandomForestClassifier。我的代码运行良好,如果我使用.predict()
。但是,要显示我使用的概率为.predict_proba(X)
,并且它始终返回相同的值,即使在X
更改时也是如此。为什么是这样以及如何解决它?RandomForestClassifier(sklearn)的predict_proba(X)似乎是静态的?
我我的代码打破的有关部分:
# ... code ... feature generation/gets the feature data
if rf is None:
rf = RandomForestClassifier(n_estimators=80)
rf.fit(featureData, classes)
else:
prediction = rf.predict(featureData) # gets the right class/always different
proba = rf.predict_proba(featureData)
print proba # this prints always the same values for all my 40 classes
有趣的是max(proba)
检索类.predict()
回报在第一个运行。由于.predict()
正在按预期工作,我相信这个错误在sklearn的一边,也就是说我想有一个标志需要设置。
有没有人有想法?
感谢您的时间有某种加载错误为'X'。不过,我仍然想知道为什么'预测()'成功了。谢谢你帮了我很多 – user3085931