# How to calculate the expected loss of a credit card transaction?

I have used an algorithm to calculate the probability of a credit card transaction to be fraudulent. The algorithm outputs a classification (fraud/no fraud) and the probability of each, such that $P(\text{fraud}) + P(\text{no fraud}) = 1$. I want to rank the transactions to be manually reviewed not only by the probability of it being fraudulent, the amount at risk in each transaction.

Currently, I am using $(P(\text{no fraud})*amount)-(P(\text{fraud})*amount)$ to calculate some sort of net expected profit. My goal is to rank all transactions by the expected loss they may cause to my business. I have considered instead ranking transactions only by $P(\text{fraud})*amount$, i.e., by expected loss. Do any of these two equations make sense? What would be a better alternative?

• If the transaction is not fraudulent, is amount the expected gain? I very much doubt it, and if it isn't, the P(no_fraud)*amount term doesn't make much sense. – Mark L. Stone Jun 15 '16 at 20:44
• My understanding is that the expected profit is the amount to be gained in a scenario times the probability of that scenario taking place. Can you elaborate on why do you disagree with P(no_fraud)*amount as a measure of expected gain. Also, do you think that for the purpose of ranking the transactions expected loss is a better alternative (i.e. P(fraud)*amount). If not, what else would you suggest? Thanks! – Manuel Q Jun 15 '16 at 21:09
• Is amount the gain if transaction is not fraudulent? Isn't there only a certain profit margin less than 100%? You need to be clear on how much you gain if transaction is not fraudulent and how much you lose if it is fraudulent. This may depend on the merchant and type of goods or services offered. – Mark L. Stone Jun 15 '16 at 23:04

A credit card transaction benefits the merchant (seller) and the credit card provider. Credit card provider takes a fees which is close to 1% to 3% for each transaction generally (numbers are indicative, can vary across regions, type of merchants etc) which can be considered as profit in your case, considering you are modelling this for credit card providers. Let this fees be r. Also assume that all fraud transactions are realized by credit card provider only.

Expected Profit on a non-fraud transaction = Amount * r - (average cost per transaction, but lets ignore this as of now)

Expected loss for a fraud transaction = Amount

Net expected profit for any transaction =P(non-fraud) * r * Amount - P(fraud) * Amount. So ideally you should rank your transaction as per this equation. This will bring big amount transactions to top even if their probability of fraud is little lower, and will bring transactions with very high probability of fraud to top as well if transaction amount is not very low. Let us know if you want to model for the merchant (seller), and I will try to answer for that as well.

The first equation seems reasonable. If you lay it out a transaction can either A - be non-fraud in which case you receive the amount (X), or the other hand B - can be fraud and you will lose X. Thus the equation you have given makes sense as it is the expected value of the transaction. Although you could go more in depth depending on what you are selling, considering the case where you have fraud you don't exactly lose the money value X but the item instead which I am assuming would cost less than X to produce.

The two things you write are equivalent. Let $p$ be the probability of a fraudulent transaction, $(1-p)$ be the probability of a non-fraudulent transaction, and $X$ be the amount of the transaction.

\begin{eqnarray*} qX-pX &=& (q-p)\cdot X \\ &=& \big((1-p)-p\big)\cdot X \\ &=& (1-2p)\cdot X \\ &:=& a\cdot X \\ \end{eqnarray*}

Note that $(1-2p) := a$, or we have defined $a$ to be $(1-2p)$. Since $p$ is the only factor affecting $a$, if you sort your list of $pX$ from highest to lowest, you're going to get the same ranking as if you sorted by $aX$. (Well, the two lists will be exactly flipped, so if you sorted $pX$ from highest to lowest, it's the same as sorting by $aX$ from lowest to highest.)

For the expected loss of a given transaction, it will be $\sum_{i=1}^n L_iP_i$, where $L_i$ is the loss of that transaction and $P_i$ is the probability of that instance occurring. Let's say a transaction is fraudulent 20% of the time. If $L_i=0$ when the transaction is non-fraudulent but $L_i=amount$ when that transaction is fraudulent (where $amount$ is the amount involved in the transaction), then the expected loss will be:

\begin{eqnarray*} \text{Expected Loss} &=& E[L] \\ &=& \sum_{i=1}^n L_iP_i \\ &=& 0 \cdot 0.8 + (amount) \cdot 0.2 \\ &=& (amount) \cdot 0.2 \\ \end{eqnarray*}

In this case, your expected loss for a particular transaction would be 20% of that transaction, or $0.2(amount)$..

However, if you actually gained a certain amount of money if a transaction isn't fraudulent, then that must be considered. For example, if you gained 5% of the transactional amount on every non-fraudulent transaction, then your expected loss is:

\begin{eqnarray*} \text{Expected Loss} &=& E[L] \\ &=& \sum_{i=1}^n L_iP_i \\ &=& -0.05 \cdot(amount) \cdot 0.8 + (amount) \cdot 0.2 \\ &=& -.04 \cdot (amount) + (amount) \cdot 0.2 \\ &=& .16 \cdot (amount) \end{eqnarray*}

In this case, your expected loss would be 16% of that transaction, or $0.16(amount)$.

If you wanted to sum the expected loss over a set of transactions, you can calculate this for each transaction and sum the losses, as you might intuitively think.