SafeML: Detecting Concept Drift Before Machine Learning Accuracy Drops
Updated: Nov 17
In short: SafeML is a runtime safety-monitoring method developed at the University of Hull. It rests on one idea: a classifier’s validated accuracy can only be trusted while the statistical distribution of its operational inputs stays close to that of its training data. SafeML measures that distance with empirical statistical measures and turns it into a degree of confidence in the model’s outputs, warning engineers when concept drift makes the model unreliable.
Key takeaways
Concept drift (operational data that differs statistically from the training data) can silently degrade a model’s accuracy.
In this article’s lung-cancer example, accuracy is 93% on validation data but falls below 70% when the classifier meets atypical cases.
SafeML compares the distributions of training and operational features and reports how much confidence the outputs deserve.

What is SafeML?
SafeML will be useful to you if you develop a dependable system with components that employ Machine Learning (ML).
A key question that you may wish to address is whether and when the reasoning of these components can be trusted.
Imagine that you design an autonomous car, and you wish to incorporate an ML system that uses a camera to read the state of traffic lights. You may have trained this system extensively with large volumes of data, but this system may fail in adverse environmental conditions with potentially catastrophic consequences.
In another scenario, an algorithm may learn to detect a disease by examining images of typical symptoms. The algorithm may be biased towards these typical symptoms and may give false negatives when encountering atypical symptoms of the disease.
In a third scenario, an algorithm may have been trained to detect features on a human face by examining pictures of a certain ethnic group. However, it may fail to detect similar features correctly when it encounters images of people of different ethnic origins.
This type of bias in ML systems is currently attracting research. At the University of Hull, we are developing a method called SafeML which uses statistical techniques to detect and report on such biases.
How does concept drift affect accuracy?
To illustrate the problem and the principle that underpins SafeML as a solution, imagine a system that detects lung cancer and has been trained with images that show symptoms of the disease. The system classifies an image in three classes “negative” “early stages” and “advanced stage” of the disease. During training, the accuracy of the classifier can be estimated by validating the output of the algorithm using images where the outcome is already known. This accuracy can be predicted, and we assume that it is high before the system is deployed for operation on new unverified data. It is precisely the task of the classifier to diagnose and classify correctly such data. And the question arises: can we trust the predicted accuracy established during training in these new situations?
In SafeML we take the view that accuracy can be trusted only if the statistical distribution of inputs that affect a classification has been shown not to drift much from that of these inputs in the training set. Such drift can confuse an ML algorithm. The phenomenon is called “concept drift” and is illustrated in Fig.1.

Fig.1. Concept drift
From left to right you see statistical distributions of “training” “validation” and “operational” data in two cases. The second case shows concept drift between “training” and “operational” data is detected.
Let us imagine that in the example of the medical diagnosis of lung cancer, the algorithm has been trained using a verified dataset of common symptoms. We have used 80% of the dataset to train the algorithm and 20% to validate it. Because training and validation data are similar statistically, i.e. both sets include common symptoms, the algorithm performs well in validation with 93% accuracy.
In the “normal case” of operation, the algorithm encounters images that are very close statistically to the training data and performs well with accuracy that matches and exceeds the one established during validation.
However, in the case of “concept drift”, the algorithm encounters images that are statistically different from the training data, perhaps of atypical symptoms of the disease. This confuses the algorithm, and the classifier reports false negatives (no disease) and classifies wrongly in general. The accuracy drops below 70%.
How does SafeML detect distribution shift?
To address this problem, SafeML uses well-known empirical statistical measures to measure this distributional shift between training and operational features that influence an output. Shifts detected are interpreted to a degree of confidence in the accuracy of classifications made by the ML algorithm.
When SafeML reports confidence on the reasoning, the output of the algorithm can be trusted, and any further decision is less likely to cause harm. Fig.2 shows the SafeML concept.

Fig.2. SafeML
Further reading on SafeML
SafeML Kaggle Story that contains more information and code
Papers:
- SafeML code and resources in Github
Frequently asked questions about SafeML
What is concept drift?
A change between the statistical distribution of the data a model was trained on and the data it meets in operation. It can confuse a classifier and reduce its accuracy without any visible error.
Which statistical measures does SafeML use?
The original SafeML paper uses distances between empirical cumulative distribution functions (ECDFs), including the Kolmogorov–Smirnov, Kuiper, Anderson–Darling and Wasserstein distances.
Is SafeML code available?
Yes. Code and resources are on GitHub, and the method is described in the paper “SafeML: Safety Monitoring of Machine Learning Classifiers through Statistical Difference Measure” (2020).




Comments