ROC Curve, Lift Chart and Calibration Plot: Miha Vuk, Toma Z Curk
ROC Curve, Lift Chart and Calibration Plot: Miha Vuk, Toma Z Curk
1, 2006, 89-108
Abstract
This paper presents ROC curve, lift chart and calibration plot, three well known
graphical techniques that are useful for evaluating the quality of classification models
used in data mining and machine learning. Each technique, normally used and stud-
ied separately, defines its own measure of classification quality and its visualization.
Here, we give a brief survey of the methods and establish a common mathematical
framework which adds some new aspects, explanations and interrelations between
these techniques. We conclude with an empirical evaluation and a few examples on
how to use the presented techniques to boost classification accuracy.
1 Introduction
In research result presentation of machine learning systems, we observe their performance
under a specific setting. The way we observe their performance is tightly connected with
the specific problem that they are solving. Classification problems are most common in
machine learning and this paper will present three techniques for improving and evaluat-
ing classification models (called classifiers) used for automatic classification. ROC curve,
lift chart and calibration plot are techniques for visualizing, organizing, improving and se-
lecting classifiers based on their performance. They facilitate our conception of classifiers
and are therefore useful in research and in result presentation.
This paper gives a quick introduction to all three techniques and practical guidelines
for applying them in research. This part is already known from literature. The main con-
tribution of this paper is a deeper theoretical background with some new explanations of
areas under curves and a description of new interrelations between these three techniques
and between derived measures of classification performance.
The paper is divided in two parts. The first part (Sections 3 to 6) covers the theory.
In Section 3 we introduce the concept of a classifier and explain the difference between
binary and probabilistic classifiers. In Section 4 we present ROC curve, area under the
curve (AUC) and show how to use ROC curve to improve classification accuracy. In
Section 5 we present lift chart and describe the interrelation between area under the ROC
curve and lift chart curve. In Section 6 we introduce the calibration plot and show how
ROC curve, lift chart and the area under both curves can be derived from the calibration
1
Department of Knowledge Technologies, Jožef Stefan Institute, Slovenia; [email protected]
2
University of Ljubljana, Faculty of Computer and Information Science, Slovenia;
[email protected]
The two authors contributed equally to this work.
90 Miha Vuk and Tomaž Curk
plot. In the second part (Section 7) of this paper we report on an empirical validation
of the proposed method to improve classification accuracy using ROC analysis and give
some practical examples. We show the presented techniques and approaches on different
classifiers and data sets. The paper’s main contributions can be found in Sections 4.1, 5.1
and 6.
2 Related work
Most books on data mining and machine learning (Witten, 2000; Phyle, 1999) dedicate
relatively short sections to a description of ROC curves and lift charts. ROC curves
[19, 20, 21] have long been used in signal detection theory to depict the tradeoff be-
tween hit rates and false alarm rates of classifiers (Egan, 1975; Centor, 1991). They are
widely used by the decision making community and in medical diagnostic systems (Han-
ley and McNeil, 1982). A deeper explanation and implementation details for applying
ROC analysis in practical research can be found in (Fawcett, 2003; with Provost, 2001,
1997).
Lift chart [14, 15, 16] is well know in the data mining community specialized in
marketing and sales applications (Berry and Linoff, 1999). Apart from their primarily
presentational purpose lift charts have not been much studied.
The term calibration and using graphs to present calibration quality is common in
all scientific and engineering fields including statistics and data mining. There is not a
single common name for calibration plots as they are often referenced as calibration map,
calibration graph, calibration chart, etc. In this paper we will use the term calibration plot.
Good references for calibration classifiers are Cohen, Goldszmidt (2004) and Zadrozny,
Elkan (2002).
3 Classifiers
One of the important tasks in data mining and machine learning is classification. Given a
set of examples that belong to different classes we want to construct a classification model
(also called a classifier) that will classify examples to the correct class.
When constructing a classifier we usually assume that the test set of examples is not
known, but there are some other previously known data that we can use to extract the
knowledge. The phase of constructing the classifier is called training or learning and
the data used in this phase are called training (learning) data or training (example) set.
Afterwards we evaluate the classifier on some other data called test data or test set.
It is often hard or nearly impossible to construct a perfect classification model that
would correctly classify all examples from the test set. Therefore we have to choose a
suboptimal classification model that best suits our needs and works best on our problem
domain. This paper presents different quality measures that can be used for such classifier
selection. It also presents the techniques for visual comparison of different classification
models.
An example: We want to develop a classification model to diagnose a specific illness.
Each patient is described by several attributes on which decisions of our model are based.
ROC Curve, Lift Chart and Calibration Plot 91
Patients in the training set have an already known diagnosis (belong to either class ill or
healthy) and data about these patients are used to learn a classifier. The classifier is then
applied on the test set of patients where only attributes’ values without class information
are passed to the classifier. Finally, predictions are compared with the medically observed
health status of patients in the test set, to assess the classifier’s predictive quality.
In the example above we could use a classifier that makes a binary prediction (i.e. the
patient is either ill or healthy) or a classifier that gives a probabilistic class prediction 3 to
which class an example belongs. The fist is called binary classifier and the later is called
probabilistic classifier.
FP TP TP + FP
FPrate = TPrate = = Recall Yrate = (3.3)
N P P +N
TP TP + TN
Precision = Accuracy = (3.4)
TP + FP P +N
Precision and Accuracy are often used to measure the classification quality of binary
classifiers. Several other measures used for special purposes can also be defined. We
describe them in the following sections.
This implies that each pair of a probabilistic classifier and threshold t defines a binary
classifier. Measures defined in the section above can therefore also be used for probabilis-
tic classifiers, but they are always a function of the threshold t.
Note that T P (t) and F P (t) are always monotonic descending functions. For a finite
example set they are stepwise, not continuous.
By varying t we get a family of binary classifiers. The rest of this paper will focus
on evaluating such families of binary classifiers (usually derived from probabilistic clas-
sifier). The three techniques we mentioned in the introduction each offer its own way
to visualize the classification ”quality” of the whole family. They are used to compare
different families and to choose an optimal binary classifier from the family.
4 ROC curve
Suppose we have developed a classifier that will be used in an alarm system. Usually
we are especially interested in portion of alarms caused by positive events (that should
really fire an alarm) and portion of alarms caused by negative events. The ratio between
positive and negative events can vary during time, so we want to measure the quality
of our alarm system independently of this ratio. In such cases the ROC curve (receiver
operating characteristic) (Fawcett (2003), [19, 20, 21]) is the right tool to use.
ROC graph is defined by a parametric definition
Each binary classifier (for a given test set of examples) is represented by a point
(FPrate, TPrate) on the graph. By varying the threshold of the probabilistic classifier,
we get a set of binary classifiers, represented with a set of points on the graph. The ROC
curve is independent of the P : N ratio and is therefore suitable for comparing classifiers
when this ratio may vary.
An example of a probabilistic classifier and its results on a given test set are shown in
Table 1. Figure 1 shows the ROC curve for this classifier.
ROC graph in the above example is composed of a discrete set of points. There are
several ways to make a curve out of these points. The most common is using the convex
hull that is shown in Figure 2.
Such representation also has a practical meaning, since we are able to construct a
binary classifier for each point on the convex hull. Each straight segment of a convex hull
is defined with two endpoints that correspond to two classifiers. We will label the first one
A and the other one B. A new (combined) classifier C can be defined. For a given value
of parameter α ∈ (0, 1) we can combine the predictions of classifiers A and B. We take
the prediction of A with probability α and the prediction of B with probability 1 − α. The
combined classifier C corresponds to the point on the straight segment and by varying
the parameter α we cover the whole straight segment between A and B. If the original
ROC graph corresponds to probabilistic classifier, its convex hull also corresponds to a
probabilistic classifier that is always at least as good as the original one.
Convex hull is just one approach for constructing a ROC curve from a given set of
points. Other approaches are presented in the next section.
ROC Curve, Lift Chart and Calibration Plot 93
Table 1: Probabilistic classifier. The table shows the assigned scores and the real classes of
the examples in the given test set.
Figure 1: ROC graph of the probabilistic classifier from Table 1. Thresholds are also
marked on the graph.
Figure 2: ROC graph with a convex hull of the probabilistic classifier from Table 1.
curve (e.g. the dashed line in Figure 1) obtained from a given set of points and we will
also assume that our probabilistic classifier assigns a different score to each example.
Then the above formula instructs us: for each negative example count the number of
positive examples with a higher assigned scores than the negative example, sum it up
and divide everything with P N . This is exactly the same procedure as used to compute
the probability that a random positive example has a higher assigned score than random
negative example.
Remark P (X) denotes the probability of event X and has no connection with P which
denotes the number of positive examples in test set.
If we allow that several positive and several negative examples can have the same
assigned score, then there are several equivalent approaches to construct a ROC curve,
each resulting in different AU C. Table 2 shows an example of such classifier and Figure 3
shows ROC curves constructed using approaches defined below.
The equation 4.3 still holds true if two adjacent points are connected with lower sides
of a right-angled triangle (see Figure 3). We will label the AUC computed using this
approach as AROC1 .
A more natural approach is connecting the two adjacent points with a straight line.
AUC computed using this approach will labeled as AROC2 . To compute AROC2 we must
define the Wilcoxon test result W (see Hanley, McNeil (1982)).
1, if xp > xn
S(xp , xn ) = 21 , if xp = xn (4.5)
0, if xp < xn
ROC Curve, Lift Chart and Calibration Plot 95
1 X X
W = S(xp , xn ) (4.6)
P N x ∈pos. x ∈neg.
p n
Table 2: Probabilistic classifier that assigns the same score (0.4) to two examples in a given
test set.
s0.4 s0.2
1
AROC2
s
0.6 s0.4
AROC1
TPrate
s0.9
0 s∞
0 FPrate 1
Using the formulae above we can compute AROC1 and AROC2 directly (without a graph)
and they both have a mathematical meaning and interpretation. In general, both measures
tell us how well a classifier distinguishes between positive and negative examples. While
it is an important aspect of a classification, it is not a guarantee of good classification
accuracy nor of other classifier’s qualities.
96 Miha Vuk and Tomaž Curk
If the proportion of examples with the same assigned value between all examples is
small, then the difference between AROC1 and AROC2 becomes negligible.
We can define other iso-performance lines for other measures of classification quality
(e.g. error cost). Another important aspect of ROC performance analysis is the ability
to assign weights to positive and negative errors. Weights influence just the angle of the
tangential line and thus influence the selection of the optimal binary classifier.
5 Lift chart
Although developed for other purposes, lift chart (Witten, Frank (2000), [14, 16, 15])
is quite similar to the ROC curve. We will therefore focus on the differences between
them. The reader can find the missing details in Section 4.
Lift chart is a graph with a parametric definition
TP(t) + FP(t)
x = Yrate(t) = , y = T P (t). (5.1)
P +N
Similarly as explained for ROC curve (Section 4), each binary classifier corresponds
to a point on a graph in this parametric space. By varying the threshold of a probabilistic
classifier we get a set of points, i.e. set of binary classifiers. The curve we get by drawing
a convex hull of the given (binary) points is called a lift chart. Again it holds true that
each point on the convex hull corresponds to a combined classifier and the probabilistic
classifier that corresponds to the convex hull is always at least as good as the original
classifier from which the hull was derived.
Figure 5 shows an example lift chart for the marketing operation described above.
Unlike the ROC curve, lift chart depends on the P : N ratio.
98 Miha Vuk and Tomaž Curk
Figure 5: A typical marketing lift char for sending advertisements to 1000 households.
Table 3: Probabilistic classifier that assigns the same score (0.4) to two examples in the
given test set.
Num Class Score
1 p 0.9
2 p 0.6
3 n 0.5
4 n 0.4
5 p 0.4
6 n 0.2
s0.4 s0.2
P
Alif t2
0.6 s 0.5 s
TP
0.9 s
Alif t1
0 s∞
0 Yrate 1
As we have seen for ROC curves, it is possible to compute Alift1 and Alift2 directly
(without a graph) using formulae 5.2 and 5.5. If the number of all examples is big and the
proportion of examples with the same assigned score between all examples is small, then
the difference between Alift1 and Alift2 becomes negligible.
A more interesting problem for lift charts is finding the point of maximal profit which
is tightly connected to the weighted classification accuracy. For this purpose we assume
profit consists of fixed benefit for every correctly classified example, reduced for a fixed
cost for every misclassified example. The point of optimal profit is where the (statistically)
expected benefit of the next positive example is equal to its expected cost.
Each point on a lift chart corresponds to a binary classifier, for which we can define
classification accuracy and other quality measures. To compute classification accuracy
we need to know P and N , but just to find the optimal point (with optimal classification
accuracy or profit) the P : N ratio will suffice.
From the equation
TP + TN TP + N − Yrate(P + N ) + TP
Accuracy = = (5.6)
P +N P +N
we get a definition of an iso-performance line of constant classification accuracy.
Accuracy(P + N ) − N + Yrate(P + N ) P +N Accuracy(P + N ) − N
TP = = Yrate+
2 2 2
(5.7)
In both described cases (accuracy and profit) the iso-performance lines are straight and
parallel, so it is easy to find a tangent to the curve. A graphical example is shown in
Figure 7.
s s0.2
P 0.4
sg s0.5
0.6
TP
s0.9
0 s∞
0 Yrate 1
Note that other points on the curve can have considerably lower classification accu-
racy. There is also no direct connection between classification accuracy and area under
lift chart.
We can define other iso-performance lines for other measures of classification quality
(e.g. profit or error cost). Adding weights to positive and negative errors impacts only the
angle of these lines.
ROC Curve, Lift Chart and Calibration Plot 101
6 Calibration plot
Calibration plot (Cohen, Goldszmidt, 2004) is quite different from the two previous
curves. In Section 3.2 we introduced probabilistic classifiers. Such classifiers assign each
example a score (from range [0, 1]) or probability that should express the true probability
that an example belongs to the positive class. One of the signs that a suitable classification
model has been found is also that predicted probabilities (scores) are well calibrated, that
is that a fraction of about p of events with predicted probability p actually occurs.
Calibration plot is a method that shows us how well the classifier is calibrated and
allows us to calibrate it perfectly (Zadrozny, Elkan (2002)). Nevertheless, even after per-
fect calibration of a classifier, its ROC and lift chart are not affected and its classification
ability remains unchanged.
Calibration plot is a graph with a parametric definition
x = true probability, y = predicted probability. (6.1)
True probabilities are calculated for (sub)sets of examples with the same score. If there
are not enough examples with the same score, examples with similar score are grouped
by partitioning the range of possible predictions into subsegments (or bins). In each sub-
segment the number of positive and negative examples is counted and their ratio defines
the true probability. When working on a small test set the points are often spread out,
therefore a LOESS [17] method is used in such cases to get a smooth curve. Additionally,
true example distribution in the test set is presented by showing positive examples above
the graph area (on the x-axis) and negative example below the graph area, in what is called
”a rag” (see Figure 8). A good classifier (with good classification accuracy) gathers pos-
itive examples near the upper right corner (near 1) and negative examples near lower left
corner (near 0).
The P : N ratio influences the true probabilities, so it also influences the plot. Calibra-
tion plot only shows the bias of a classifier and has no connection with the classification
quality (accuracy). Nonetheless, if a classifier turns out to be very biased, it is probably
better to find a different one.
A perfectly calibrated classifier is represented by a diagonal on the graph, which can
be quite misleading for the previously mentioned fact that It is possible to calibrate al-
most every classifier to express the diagonal on the graph without improving its quality
of classification. The calibration preserves the ”ordering” of examples that the classifier
makes by assigning scores (which is tightly connected to the classifier’s ability to distin-
guish between the two classes). If the original classifier assigned the same value to two
examples, the same will hold true also after calibration.
perfectly calibrated (unbiased) classifier 6= perfect classifier
Transforming a calibration plot into a ROC, lift chart or calculating accuracy requires
knowledge about the distribution density % of the classifier’s predictions, and the values of
P and N . Let p denote the true probability that an example with a given prediction (score)
is positive, o denotes a classifier’s prediction and T denotes the classification threshold.
It holds true Z 1
%(o) do = 1. (6.2)
0
102 Miha Vuk and Tomaž Curk
Z T Z T
FN TN
= p(o)%(o) do, = (1 − p(o))%(o) do. (6.4)
P +N 0 P +N 0
From these we can derive the ROC and lift curve and all the derived measures.
For example we will derive AROC :
Z 1
TP FP
AROC = d (6.5)
0 P N
2 Z 1
(P + N ) TP FP
= d (6.6)
P ·N 0 P +N P +N
2 Z 1 Z 1
(P + N )
= p(o)%(o) do (−(1 − p(T ))%(T ))dT (6.7)
P ·N 0 T
(P + N )2 1
Z Z 1
= (p(T ) − 1)%(T ) p(o)%(o) do dT (6.8)
P ·N 0 T
Similar equations can be derived for Alift , classification accuracy and other measures
of classification quality. None of these derivations seem to be obviously useful, but it is
good to know that they do exist. For example, if we are given a calibration plot and we
know the prediction distribution %, we can calculate the classification results (TP, FP, etc.)
In such case the above transformation might be useful, but besides that the primary and the
only purpose of the calibration plot is classifier calibration. To the best of our knowledge,
we are not aware of any other mathematical meaning and purpose of the calibration plot.
ROC Curve, Lift Chart and Calibration Plot 103
Classification accuracy remained same in seven cases; these are all cases where classifiers
achieved high AROC and classification accuracy, and where further improvements are hard
to achieve. Overall the threshold selection method is performing as expected - generally
increasing the classification accuracy where possible.
We will now focus on two extreme examples with maximum increase and maximum
decrease in classification accuracy and explain the reasons for it. Naive Bayesian classifier
has the highest increase on the tic tac toe data set. The classifier has a relatively low
AUC of only 0.741 and the default classification accuracy 69.5%. Looking at the ROC
curve and optimal threshold analysis in Figure 9 one can see that the optimal threshold for
predicting positive class ”p” is to = 0.403. The default threshold 0.5 is laying on the ROC
curve below the curve’s convex hull (point of default threshold 0.5 is shown in Figure 9)
which is the reason for lower classification accuracy when using the default threshold.
Predicted Class: p
1
0.9
0.5
0.8
0.7
0.6
TP Rate (Sensitivity)
0.5
0.4
0.3
0.2
0.1
Figure 9: ROC curve and its convex hull for the naive Bayesian classifier on the tic tac toe
data set. The point with optimal threshold (to = 0.403) when predicting positive class ”p” is
where the iso-performance tangent intersects the ROC curve. Slope of the tangent was
calculated using the a priori class distribution. Point for the classifier with default threhold
(0.5) is shown on ROC curve.
A second example is the classification tree classifier used on the promoters data set.
Comparing the calibration plots in Figure 10 of both classifiers used (naive Bayes and
classification tree) on the promoters data set one can see that the tree returns extremely
uncalibrated probabilities. This is a clear sign of the difficulty for the tree learning method
to deal with the promoters problem domain. Bad calibration is also partly the result of
the tree’s tendency to return a relatively small number of different probabilistic scores
when classifying examples (now shown). We observed this in the classification plot rug
for the tree classifier and it can be also observed in the shape of the ROC curve shown
in Figure 11. The ROC curve of the Bayesian classifier has many more ”steps” than the
106 Miha Vuk and Tomaž Curk
tree’s curve, which is a direct indication of a more diverse set of scores it can return on
the given data set. The main reason for the decrease in classification accuracy is the tree’s
model instability. Looking at Table 4 we can see that the average optimal threshold is
to = 0.56 which could be an indication of good calibration, what we saw is not the case
here. Standard deviation of the optimal threshold across the ten folds is 0.316 (not shown
for the others) which only confirms the tree’s instability and explains why small changes
in the threshold could have great consequences on the final classification accuracy.
pp
1
0.9
0.8
0.7
0.6
actual probability
0.5
0.4
0.3
0.2
0.1
Figure 10: Calibration plots for naive Bayesian classifier (solid line), and decision tree
classifier (dashed line) when predicting positive class ”pp.”
8 Conclusion
Three different graphical techniques (ROC curve, lift chart and calibration plot) used
to evaluate the quality of classification models were presented. Basic facts about each
technique are well known from literature, but this paper presents a common framework,
stresses and derives the similarities, differences and interrelations between them. Their
mathematical meaning and interpretation was given (more precisely than in related pa-
pers), with special focus on different measures of classification quality that are closely
related to these three techniques. The relations and possible transformations between the
curves and between some derived measures were also presented. These extensions are, to
the best of our knowledge, the main novelty and contribution of this paper.
9 Acknowledgement
The authors would like to thank prof. dr. Blaž Zupan for the initial idea and help. The
work done by T.C. was supported by Program and Project grants from the Slovenian
Research Agency.
ROC Curve, Lift Chart and Calibration Plot 107
Predicted Class: pp
1
0.9
0.42
0.8 0.52
0.7
0.6
TP Rate (Sensitivity)
0.5
0.4
0.3
0.2
0.1
Figure 11: ROC curve for naive Bayesian classifier (solid line), and decision tree classifier
(dashed line) when predicting positive class ”pp.” Points on ROC curve closest to default
threshold (0.5) are shown for the two classifiers.
References
[1] Berry, M.J.A. and Linoff, G. (1999): Data Mining Techniques: For Marketing,
Sales, and Customer Support. Morgan Kaufmann Publishers.
[2] Centor, R.M. (1991): Signal detectability: The use of ROC curves and their analy-
ses. Medical Decision Making.
[3] Cohen, I. and Goldszmidt, M. (2004): Properties and benefits of calibrated classi-
fiers, In Proceedings of ECML 2004.
http://www.ifp.uiuc.edu/ iracohen/publications/CalibrationECML2004.pdf.
[4] Demšar, J., Zupan, B. and Leban, G. (2004): Orange: From Experimental Machine
Learning to Interactive Data Mining, White Paper (www.ailab.si/orange), Faculty of
Computer and Information Science, University of Ljubljana.
[5] Egan, J.P. (1975): Signal Detection Theory and ROC Analysis, New York: Academic
Press.
[6] Fawcett, T. (2003): ROC Graphs: Notes and Practical Considerations for Data Min-
ing Researchers. HP Laboratories.
http://home.comcast.net/˜tom.fawcett/public_html/papers/ROC101.pdf.
[7] Fayyad, U.M. and Irani, K.B. (1993): Multi-interval discretization of continuous-
valued attributes for classification learning. In Proceedings of 13th International
Joint Conference on Artificial Intelligence (IJCAI-93), 1022–1027.
108 Miha Vuk and Tomaž Curk
[8] Hanley, J.A. and McNeil, B.J. (1982): The meaning and use of the area under a
receiver operating characteristic (ROC) curve. Diagnostic Radiology, 143, 29–36.
[9] Pyle, D. (1999): Data Preparation for Data Mining. Morgan Kaufmann Publishers.
[10] Provost, F. and Fawcett, T. (1997): Analysis and Visualization of Classifier Perfor-
mance: Comparison under Imprecise Class and Cost Distributions. KDD-97.
[11] Provost, F., Fawcett, T. (2001): Robust classification for imprecise environments.
Machine Learning, 42, 203–231.
[12] Zadrozny, B., Elkan, C. (2002), Transforming classifier scores into accurate multi-
class probability estimates. In Proceedings of the Eighth International Conference
on Knowledge Discovery and Data Mining (KDD’02).
http://www-cse.ucsd.edu/ zadrozny/kdd2002-Transf.pdf.
[13] Witten, I. H., Frank, E. (2000): Data Mining, Practical Machine Learning Tools and
Techniques with Java Implementations. Morgan Kaufmann Publishers.