1
我正在使用scikit-learn使用Logistic回归实现分类。 使用predict()
函数预测类别标签,而使用predict_proba()
函数打印预测概率。
为什么predict_proba函数以相反的顺序打印概率?
的代码段粘贴下面:
# Partition the dataset into train and test data
X_train, X_test, y_train, y_test = train_test_split(ds_X, ds_y, test_size=0.33, random_state=42)
y_pred = logreg.predict(X_test) # Predicted class labels from test features
y_predicted_proba = logreg.predict_proba(X_test) # Predicted probabilities from test features
的预测标签印刷作为
array([1, 1, 1, 1, 1, 1, 1, 1, 0, 1.......... and so on
相应预测概率打印为
array([[ 0.03667012, 0.96332988],
[ 0.03638475, 0.96361525],
[ 0.03809274, 0.96190726],
[ 0.01746768, 0.98253232],
[ 0.02742639, 0.97257361],
[ 0.03676579, 0.96323421],
[ 0.02881874, 0.97118126],
[ 0.03082288, 0.96917712],
[ 0.65332179, 0.34667821],
[ 0.02091977, 0.97908023],
.
'
and so on
观察,
第一预测标签 -
第一预测概率 - [0.03667012,0.96332988]
为什么0.03667012第一印刷,代替0.96332988? 它应该是另一种方式吗?
第一列是第0类的预测概率,第二列是第1类的预测概率。你是说他们应该按照从最高到最低的顺序打印? –
不,我解释的方式是首先打印概率的补充。 但现在,我的疑问已被清除。 0类的预测概率首先被打印,然后是类标签1的概率。谢谢。 – User456898