获取Scikit-Learn RandomForestClassifier输出前N个结果

dan*_*lef 2 classification machine-learning prediction random-forest scikit-learn

我想查看RandomForestClassifier预测的前N个结果,并按降序排列。

答案可能是predict_proba,但我不知道如何解释结果。

帮助赞赏!

aga*_*rs3 6

我认为您使用是正确的predict_proba。使用np.argsort来解释结果:

p = rfc.predict_proba(X)
n = 3
top_n = np.argsort(p)[:,:-n-1:-1]
Run Code Online (Sandbox Code Playgroud)

  • 如果您的类是从0到n_classes的整数;)否则,您需要使用``rfc.classes_ [top_n]`` (3认同)