'How to understand tensorflow predictions?
I learning tensorflow from beginning from youtube: https://www.youtube.com/watch?v=Cq_P8kJgjvI&t=1808s
And the last code about predictions like this:
first:
print(df_test_new.iloc[0])
print('prediction')
print(predictions[0])
and the result:
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)
}
this is in array index 3
print(df_test_new.iloc[3])
print('prediction:')
print(predictions[3])
and this is the print result:
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)
}
I still don't understand prediction meaning in tensorflow please help me to understand it.
Solution 1:[1]
From your examples I see the following:
You have data about people and every person has a label, either 1
or 0
. This is indicated in your ground truth data under label
. What those labels are representing should be explained where ever you got the data from, maybe it's data by a bank if this person should get a loan or not, where the label 1
indicates YES
and label 0
indicates NO
.
Your prediction overview lists the following information:
all_classes
list what outputs your neural net can actually deliver, in your case one of two classes (0 or 1). The concrete prediction of what your network is putting out is listed under classes
. In your first case, this is b'0'
and in your second example this is b'1'
. Those predictions indicate 0
and 1
respectively, which means that your network put out the correct prediction for your two examples since the ground truth listed in the data is 0
for the first person and 1
for the second person.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Noltibus |