如何理解张量流预测?

原文标题How to understand tensorflow predictions?

我从 youtube 开始学习 tensorflow:https://www.youtube.com/watch?v=Cq_P8kJgjvI&t=1808s

最后一个关于预测的代码是这样的:

第一的:

print(df_test_new.iloc[0])
print('prediction')
print(predictions[0])

结果:

age                              25
workclass                   Private
fnlwgt                       226802
education                      11th
education_num                     7
marital               Never-married
occupation        Machine-op-inspct
relationship              Own-child
race                          Black
sex                            Male
capital_gain                      0
capital_loss                      0
hours_week                       40
native_country        United-States
label                             0
new                             625
Name: 0, dtype: object
prediction
{
  'logits': array([-954.60187], dtype=float32), 
  'logistic': array([0.], dtype=float32), 
  'probabilities': array([1., 0.], dtype=float32), 
  'class_ids': array([0]), 
  'classes': array([b'0'], dtype=object), 
  'all_class_ids': array([0, 1], dtype=int32), 
  'all_classes': array([b'0', b'1'], dtype=object)
}

这是在数组索引 3 中

print(df_test_new.iloc[3])
print('prediction:')
print(predictions[3])

这是打印结果:

age                               44
workclass                    Private
fnlwgt                        160323
education               Some-college
education_num                     10
marital           Married-civ-spouse
occupation         Machine-op-inspct
relationship                 Husband
race                           Black
sex                             Male
capital_gain                    7688
capital_loss                       0
hours_week                        40
native_country         United-States
label                              1
new                             1936
Name: 3, dtype: object

prediction:

{
   'logits': array([1222.3406], dtype=float32), 
   'logistic': array([1.], dtype=float32), 
   'probabilities': array([0., 1.], dtype=float32), 
   'class_ids': array([1]), 
   'classes': array([b'1'], dtype=object), 
   'all_class_ids': array([0, 1], dtype=int32), 
   'all_classes': array([b'0', b'1'], dtype=object)
}

我仍然不明白 tensorflow 中的预测含义,请帮助我理解它。

原文链接:https://stackoverflow.com//questions/71592442/how-to-understand-tensorflow-predictions

回复

我来回复
  • Noltibus的头像
    Noltibus 评论

    从您的示例中,我看到以下内容:

    你有关于人的数据,每个人都有一个标签,要么10。这在label下的地面实况数据中显示。这些标签代表什么应该解释你从哪里获得数据,如果这个人是否应该获得贷款,可能是银行提供的数据,标签1表示YES和标签0表示NO

    您的预测概述列出了以下信息:all_classes列出您的神经网络实际可以提供的输出,在您的情况下是两个类别(0 或 1)之一。 classes下列出了您的网络发布的具体预测。在你的第一个例子中,这是b'0',在你的第二个例子中,这是b'1'。这些预测分别表示01,这意味着您的网络为您的两个示例提供了正确的预测,因为数据中列出的基本事实是0用于第一人称,1用于第二人称。

    2年前 0条评论