# Cross entropy

The cross-entropy between two probability distributions p and q.

#### Cross entropy

True lable Distribution P (0 1 0)

#### Input

$$P (0 1 0)$$ $$Q (0.15 0.60 0.25)$$

#### Solution

Cross-entropy H(p, q) will be:
H(p, q) = -[0 * log₂(0.15) + 1 * log₂(0.6) + 0 * log₂(0.25)]
H(p, q) = 0.736

## The cross-entropy between two probability distributions p and q

The cross-entropy between two probability distributions p and q over an equivalent underlying set of
events measure the typical number of bits needed to spot an occasion drawn from the set if a coding
the scheme used for the set is optimized for an estimated probability distribution q, instead of truth
distribution p.
It is most commonly used as machine learning as a function.
Cross-entropy may be a measure from the sector of data theory, building upon entropy and usually
calculating the difference between two probability distributions. It closely associated with but is
different from KL divergence that calculates the relative entropy between two probability distributions,
whereas cross-entropy is often thought to calculate the entire entropy between the distributions.
Cross-entropy is additionally associated with and sometimes confused with logistic loss, called log loss.
Although the 2 measures are derived from a special source when used as loss functions for classification
models, both measures calculate an equivalent quantity and may be used interchangeably.

Understanding Cross-Entropy
In order to know cross-entropy, starting with the definition of the entropy, ‘
Cross-entropy, it's a measure of the degree of dissimilarities between two probability distributions,
within the reference to supervised machine learning.

Cross-Entropy is expressed by the equation;
The cross-entropy equation
Where x represents the anticipated results by ML algorithm, p(x) is that the probability distribution of
the “true” label from training samples, and q(x) depicts the estimation of the ML algorithm.
Cross-entropy may be a distinction measurement between two possible distributions for a group of
given random variables or events. It builds on the concept of data-entropy and finds the variability of
bits needed to rework an occasion from one distribution to a different distribution.
Cross-entropy examines the predictions of models with a truth probability distribution. It constantly
goes down if the predictions are mostly accurate and it also becomes zero when the prediction tends to
be perfect.

KL Divergence (Relative Entropy)
The Kullback-Liebler Divergence (KL) divided into two parts of Divergence, i.e measure the difference
between two probability distributions, a KL Divergence having value zero indicates the identical
probability distribution.
And when the potential distributions P and Q, KL Divergence is given by the equations,
For discrete distributions,
The equation shows KL Divergence for discrete distributions.
For continuous distributions,
The equation shows KL Divergence for continuous distributions.
The KL Divergence is that the average number of additional bits needed to encode the info, thanks to
the very fact that we'd like distribution q to encode the info rather than truth distribution p.
Cross-Entropy as Loss Function
Cross entropy is broadly used as a Loss Function when you optimizing classification models.
In brief, classification tasks involve one or more input variables and prediction of a category label
description, additionally, if the classification problems contain only two labels for the outcomes’
predictions refereed as a binary classification problem and if classification problems contain quite two
variables are termed as categorical or multi-class classification problems.
It can measure the achievement of a classification model that provides output in terms of probability
having values between 0 and 1. It increases because the estimated probability deviates from the
particular class label.

E.g. A model contains a sample with a known class label having a probability of 1.0 and therefore the
probability of 0.0 for other class labels, this model can measure the probability of every class label, now
the role of cross-entropy comes here, it's then wont to find the difference between the probability
distributions of various class labels. Also, cross-entropy enables one to settle on the plausible split that
reduces the uncertainty about the classification.
How to use this cross-entropy tool by taskvio.com
To use this tool you don’t have to worry about anything you just have to come to our website and then
select the tool you want to use and then you can start using it.
It tool has been created for any individual who wants to do the mathematic calculation and for those who
are students.
As you can see on your desktop you have a text box where you can input the numbers.
After you will enter the number properly you have to simply click on the calculate button to get the
proper result.
You can bookmark this tool if you want because it will be good for your future uses.

### Q. Where Uses Cross-entropy ?

A. Cross-entropy Is Commonly Used In Machine Learning As A Loss Function.