# Profit curve
URL: https://docs.datarobot.com/en/docs/classic-ui/modeling/analyze-models/evaluate/roc-curve-tab/profit-curve-classic.html

> The ROC Curve tab in DataRobot lets you generate profit curves that help you estimate the business impact of a selected model.

# Profit curve

Like the other visualization tools on the [ROC Curve](https://docs.datarobot.com/en/docs/classic-ui/modeling/analyze-models/evaluate/roc-curve-tab/roc-curve-tab-use.html) tab, profit curves are available for binary classification problems.

Profit curves help you estimate the business impact of a selected model. For many classification problems, there is asymmetry between the benefit of correct predictions and/or the penalty (or cost) of incorrect predictions. The average profit chart helps you assess a model based on your supplied costs or benefits so that you can see how those profits change with different inputs.

## Generate a profit curve

To generate a profit curve, first create a payoff matrix using:

- A confusion matrix that reports how actual versus predicted values were classified.
- Payoff values—a set of values that represent business impact (free of currency). For example, "if I identify who will default on a loan, what will the cost or benefit be for each observation for both correct and incorrect predictions?"

To generate a profit curve:

1. Select a model on the Leaderboard and navigate toEvaluate > ROC Curve.
2. Select adata sourceand set thedisplay threshold.
3. In the Matrix pane on the right, create a payoff matrix by clicking+ Add payoff.
4. Enter the name of the payoff matrix. Before you create the payoff matrix, the displayed payoff values are1for correct classifications and-1for incorrect classifications—this is not really a matrix, but instead a "placeholder" set of values to provide an initial curve visualization.
5. Enter payoff values for each category (TN, FP, FN, and TP). The payoff values determine the profit calculation that generates the profit curve.
6. ClickSave. TipThe new payoff matrix becomes available to all models in the project. You can edit or delete the matrix as needed; these changes are also reflected across the project. You can create up to six matrices.
7. Set theChartpane toAverage Profitand forDisplay Threshold, selectMaximize profit. This is the maximum profit that can be achieved using the selected payoff matrix.
8. Click the circle on the profit curve to see the average profit at that threshold. Click other areas along the curve to see how the average profit changes. Take a look at the payoff matrix to see how the TN, FP, FN, and TP counts change based on the display threshold. The total profit (or loss) iscalculatedbased on the matrix settings and reflected in the curve. In other words, the total profit/loss is the sum of the correct and incorrect classifications multiplied by the benefit or loss from each.

## View the average profit metric

To view the average profit metric:

1. ClickSelect metricsand chooseAverage Profit (for Payoff Matrix).
2. View the average profit in theMetricspane:

## Profit curve explained

The average profit curve plots the average profit against the classification threshold. The average profit curve visualization is based on two inputs:

- Theconfusion matrix, which categorizes correct and incorrect predictions, and thedisplay threshold.
- Thepayoff matrix, which assigns costs and benefits to the different types of correct and incorrect predictions (true positives/true negatives and false positives/false negatives).

Consider the following average profit curve:

The following table describes elements of the display:

|  | Element | Description |
| --- | --- | --- |
| (1) | Threshold (Probability) | The focus of the display, which plots profit against the classification point of positive versus negative. This is the point used as the basis for counts in the payoff matrix. You can set the prediction threshold to this display value. |
| (2) | Profit (Average) | Determined at each threshold from the sum of the product of each pair of confusion matrix and payoff matrix elements (with formulas described below). DataRobot generates the profit/loss based off the "right and wrong" numbers combined with configured payoff values. |
| (3) | Display threshold | Circle that denotes the threshold on the profit curve. You can set the display threshold to the maximum profit by selecting Maximize profit in the Display Threshold pulldown above the Prediction Distribution graph. |
| (4) | Profit/loss line | A line that always orients to 0 to help visualize the break even point. It indicates where values are positive versus negative based on the selected data partition. |

## Compare models based on a payoff matrix

Use the [Model Comparison](https://docs.datarobot.com/en/docs/classic-ui/modeling/analyze-models/other/model-compare.html) tab to compare how two different models handle the data. Results are based on the payoff matrix, so you must have created at least one matrix before using the comparison. Some information to evaluate in the comparison include:

- How different is the shape between the two models?
- Is there a large difference in the max profit?
- Where do the thresholds occur?

The comparison uses the same controls (data selection, graph scale, and matrix) as the individual model visualizations.

## Matrix formulas for profit curves

The profit curve plots the profit against the classification threshold. Profit is determined at each threshold from the sum of the product of each pair of confusion matrix and payoff matrix elements. Using this matrix as an example, with a total profit/loss 186:

Total profit/loss:

- True Negative (TN) = 133
- False Negative (FN) = 16
- False Positive (FP) = 8
- True Positive (TP) = 3

And corresponding payoff (P) matrix:

- P TN = 2
- P FN = –5
- P FP = –3
- P TP = 8

the net profit is the sum of the products of corresponding elements of the two matrices, calculated as follows:

`Profit = (TN * PTN) + (FP * PFP) + (FN * PFN) + (TP * PTP)`

In this example:

`(133 * 2) + (8 * (-3)) + (16 * (-5)) + (3 * 8)`

or

`266 – 24 – 80 + 24 = 186`

## Relationship of profit curves to ROC curves

A profit curve is most useful for determining an optimal classification probability threshold, supplemental to the metrics of a [ROC curve](https://docs.datarobot.com/en/docs/classic-ui/modeling/analyze-models/evaluate/roc-curve-tab/roc-curve-classic.html). That is, while the ROC curve can help you find the “best” threshold based on the various statistics or your domain expertise, a profit curve helps you pick a threshold based on the costs of true and false positive and negative predictions. It provides a sense of model sensitivity in the context of your business problem—a gentle sloping curve suggests more flexibility, while a sharp pitch tells you what threshold area to avoid. The shape depends on the selected model and the payoff values assigned.

By adding [payoff values in the profit matrix](https://docs.datarobot.com/en/docs/classic-ui/modeling/analyze-models/evaluate/roc-curve-tab/profit-curve-classic.html#create-a-payoff-matrix), you create a multiplicative effect that can give you total profit/loss estimates, with varying inputs to allow comparison. The profit curve uses the same data as the ROC curve, meaning that when the threshold is the same, the confusion matrix counts in each visualization are the same. The threshold set for prediction output is shared between the profit curve and ROC Curve.

## Profit Curve considerations

- Because you cannot change the Prediction Threshold value after a model has been downloaded or deployed, there is slight delay in displaying the threshold while DataRobot checks the model status.
- Using the profit curve is not recommended for baseline (majority class classifier) models.
- The payoff matrix shows weighted counts (and those weighted counts are used to calculate profit).

---
