scikit-learn中predict_proba的输出结果

6
假设我有一个数据样本,其中有两个标记为0和1的类。当我运行`output = clf.predict_proba(X_input)`时,`output`中的每一行都包含2列,对应于每个类别的概率。
第一列表示0或1类的概率吗?GradientBoostingClassier的predict_proba方法说:
"The class probabilities of the input samples. The order of the classes corresponds to that in the attribute classes_."
这是否意味着数据样本中的第一个元素无论是0还是1都对应于`predict_proba`输出中的第一列呢?
1个回答

6

通常,分类器会有一个名为classes_的属性,这个属性将在拟合时填充并存储类别。 predict_proba方法输出的顺序将与该属性中的顺序相同。

例如:

nb = MultinomialNM()
nb.fit(some_gender_data)
nb.classes_
array(['F', 'M'], dtype='<U1')

据我所知,sklearn中的所有分类器在拟合后都具有此属性。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接