<p>To transform your logits <code>[-5,1,2]</code> into probabilities you can use the <a href="https://en.wikipedia.org/wiki/Softmax_function" rel="nofollow noreferrer">softmax function</a>.  This would get you <code>p = [0.000666195, 0.268762254, 0.730571551]</code>.</p>

CC BY-SA 4.0
2022-10-27T23:40:33.140Z
2022-10-27T23:40:33.140Z
Snehal Patel
<p>I am trying to figure out the best way to calculate the probability a sentence belongs to some category.
For simplicity sake, lets assume that the sentence is &quot;yellow fruit&quot;.
Next, I use the an BERT classifier to get a classification result [-5,1,2] with the categories [apple, orange, banana].</p>
<p>The array simply tells us how strong is the signal that corresponds to a category. In this case -5 for apple, 1 for orange, and 2 for banana.
The answer to this classification is &quot;banana&quot; since 2 is the max number in the [-5,1,2] array, and it position corresponds to the category &quot;banana&quot;.
Therefore, we know that &quot;yellow fruit&quot; is most-likely a banana.</p>
<p>Next, I have a table of likelihood of purchase for apples, oranges and bananas:</p>
<p>Apple: 80%</p>
<p>Orange: 10%</p>
<p>Banana: 50%</p>
<p>I need to calculate the likelihood of customer purchase for sentence &quot;yellow fruit&quot;.
Therefore, I am given the sentence &quot;yellow fruit&quot;, the classification vector [-5,1,2] the classification categories [apple, orange, banana] and the likelihood table for purchase [0.8,0.1,0.5]</p>
<p>How do I calculate the the likelihood of purchase for the sentence &quot;yellow fruit&quot; ?</p>

<natural-language-processing><classification><bert><probability>
How to classify data into organised groups by using a resulting classification vector and a set of probabilities?
Damir Olejar
# How to classify data into organised groups by using a resulting classification vector and a set of probabilities?

(Asked by: username_0 on 2022-10-27)

I am trying to figure out the best way to calculate the probability a sentence belongs to some category.
For simplicity sake, lets assume that the sentence is "yellow fruit".
Next, I use the an BERT classifier to get a classification result [-5,1,2] with the categories [apple, orange, banana].

The array simply tells us how strong is the signal that corresponds to a category. In this case -5 for apple, 1 for orange, and 2 for banana.
The answer to this classification is "banana" since 2 is the max number in the [-5,1,2] array, and it position corresponds to the category "banana".
Therefore, we know that "yellow fruit" is most-likely a banana.

Next, I have a table of likelihood of purchase for apples, oranges and bananas:

Apple: 80%

Orange: 10%

Banana: 50%

I need to calculate the likelihood of customer purchase for sentence "yellow fruit".
Therefore, I am given the sentence "yellow fruit", the classification vector [-5,1,2] the classification categories [apple, orange, banana] and the likelihood table for purchase [0.8,0.1,0.5]

How do I calculate the the likelihood of purchase for the sentence "yellow fruit" ?

**Tags:** natural-language-processing, classification, bert, probability


---

## 1 answers

### Answer by username_1 on 2022-10-27. Score: 2 | Accepted answer

To transform your logits `[-5,1,2]` into probabilities you can use the [softmax function](https://en.wikipedia.org/wiki/Softmax_function). This would get you `p = [0.000666195, 0.268762254, 0.730571551]`.


---

