<p>If you are using binary cross-entropy as loss function, the output of Sigmoid functions represent the probability of <span class="math-container">$\mathbb{P}[y=1]$</span>. Hence, it means that <span class="math-container">$\mathbb{P}[y=0] = 1 - \mathbb{P}[y=1]$</span>.
Therefore, when the output is <span class="math-container">$0.09$</span>, it means that the prediction is <span class="math-container">$y=0$</span> as it is more probable (<span class="math-container">$1-0.09 = 0.91$</span>).</p>

CC BY-SA 4.0
2024-01-01T20:44:31.160Z
2024-01-01T21:14:30.083Z
2024-01-01T21:14:30.083Z
OmG
<p>I use a Keras EfficientNetB7 and transfer learning to solve a binary classification problem. I use <code>tf.keras.layers.Dense(1, activation=&quot;sigmoid&quot;)(x)</code> for my final layer.</p>
<p>My labels are encoded as the following for the model.fit():</p>
<pre><code>[[1.]
 [1.]
 [0.]
 [1.]
  ...
 [1.]
 [1.]
 [0.]]
</code></pre>
<p>My question is about the output of the <code>model.predict()</code>. For example, if the output is <code>[[0.09122807]]</code>, does this mean that the prediction is class 1. or 0.?</p>
<p>Initially, I assumed it would have been class 0. but my model predicts the opposite of this assumption. In some stackoverflow posts, I saw that the output should be used 1 - p where p is the probability of class 1.</p>
<p>There is conflicting information on the net; hence, wanted to ask your guidance.</p>

CC BY-SA 4.0
2024-01-02T05:12:07.237Z
It is nearer to 0 than 1 which means the result label is 0.
Hiren Namera
<machine-learning><tensorflow><keras><binary-classification><sigmoid>
If the output is 0.09, does this mean that the prediction is class 1 or 0?
Doug
# If the output is 0.09, does this mean that the prediction is class 1 or 0?

(Asked by: username_0 on 2023-12-30)

I use a Keras EfficientNetB7 and transfer learning to solve a binary classification problem. I use tf.keras.layers.Dense(1, activation="sigmoid")(x) for my final layer.
My labels are encoded as the following for the model.fit():
[[1.]
 [1.]
 [0.]
 [1.]
  ...
 [1.]
 [1.]
 [0.]]

My question is about the output of the model.predict(). For example, if the output is [[0.09122807]], does this mean that the prediction is class 1. or 0.?
Initially, I assumed it would have been class 0. but my model predicts the opposite of this assumption. In some stackoverflow posts, I saw that the output should be used 1 - p where p is the probability of class 1.
There is conflicting information on the net; hence, wanted to ask your guidance.

**Tags:** machine-learning, tensorflow, keras, binary-classification, sigmoid

> **Comments:**
> **username_1**: It is nearer to 0 than 1 which means the result label is 0.  

---

## 1 answers

### Answer by username_2 on 2024-01-01. Score: 3 | Accepted answer

If you are using binary cross-entropy as loss function, the output of Sigmoid functions represent the probability of $\mathbb{P}[y=1]$. Hence, it means that $\mathbb{P}[y=0] = 1 - \mathbb{P}[y=1]$.
Therefore, when the output is $0.09$, it means that the prediction is $y=0$ as it is more probable ($1-0.09 = 0.91$).


---

