0
0
MLOpsdevops~10 mins

Data drift detection basics in MLOps - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Data drift detection basics
Collect baseline data
Train model on baseline
Collect new incoming data
Compare new data to baseline
Calculate drift metrics
Is drift above threshold?
NoContinue monitoring
Yes
Trigger alert or retrain model
This flow shows how data drift detection compares new data to baseline data, calculates metrics, and triggers alerts if drift is detected.
Execution Sample
MLOps
baseline_data = [10, 12, 11, 13, 12]
new_data = [10, 15, 11, 14, 20]
differences = [abs(n - b) for n, b in zip(new_data, baseline_data)]
drift = sum(differences) / len(baseline_data)
threshold = 3
alert = drift > threshold
print(alert)
This code calculates a simple average absolute difference between baseline and new data to detect drift and prints if alert is triggered.
Process Table
StepActionCalculationValueResult
1Calculate absolute differencesabs(10-10), abs(15-12), abs(11-11), abs(14-13), abs(20-12)[0, 3, 0, 1, 8]List of differences
2Sum differences0 + 3 + 0 + 1 + 812Total difference
3Calculate average difference12 / 52.4Drift metric
4Compare drift to threshold2.4 > 3FalseNo alert triggered
💡 Drift 2.4 is less than threshold 3, so no alert is triggered.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4
baseline_data[10,12,11,13,12][10,12,11,13,12][10,12,11,13,12][10,12,11,13,12][10,12,11,13,12]
new_data[10,15,11,14,20][10,15,11,14,20][10,15,11,14,20][10,15,11,14,20][10,15,11,14,20]
differencesN/A[0,3,0,1,8][0,3,0,1,8][0,3,0,1,8][0,3,0,1,8]
total_differenceN/AN/A121212
driftN/AN/AN/A2.42.4
threshold33333
alertN/AN/AN/AN/AFalse
Key Moments - 3 Insights
Why do we calculate the average difference instead of just the sum?
The average difference normalizes the drift metric by the number of data points, making it easier to compare across datasets of different sizes, as shown in step 3 of the execution_table.
What does it mean if the alert is False even though differences exist?
It means the total drift is not large enough to pass the threshold, so the system considers the data stable, as seen in step 4 where 2.4 is less than 3.
Why do we compare new data to baseline data?
Baseline data represents the original data distribution the model was trained on; comparing new data to it helps detect changes or drift, as shown in step 1 where differences are calculated.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3, what is the drift value calculated?
A3
B12
C2.4
DFalse
💡 Hint
Check the 'Value' column at step 3 in the execution_table.
At which step does the system decide if an alert should be triggered?
AStep 2
BStep 4
CStep 1
DStep 3
💡 Hint
Look for the step where drift is compared to threshold in the execution_table.
If the threshold was lowered to 2, what would the alert value be at step 4?
ATrue
BFalse
C12
D2.4
💡 Hint
Compare drift 2.4 to new threshold 2 in step 4 of execution_table.
Concept Snapshot
Data drift detection compares new data to baseline data.
Calculate a drift metric (e.g., average absolute difference).
Set a threshold to decide if drift is significant.
If drift > threshold, trigger alert or retrain.
This helps keep ML models accurate over time.
Full Transcript
Data drift detection basics involve comparing new incoming data to the original baseline data used to train a model. We calculate a drift metric, such as the average absolute difference between the new and baseline data points. This metric is then compared to a set threshold. If the drift exceeds the threshold, it indicates that the data distribution has changed significantly, and an alert is triggered to notify that the model may need retraining. This process helps maintain model accuracy by detecting when the data environment changes.