0
0
MLOpsdevops~10 mins

Concept drift detection in MLOps - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Concept drift detection
Start Monitoring Data Stream
Collect New Data Batch
Compare New Data to Training Data
Calculate Drift Metric
Is Drift Detected?
NoContinue Monitoring
Yes
Trigger Alert or Retrain Model
Update Model or Data Pipeline
Resume Monitoring
The flow shows how new data is monitored continuously, compared to original training data, and if drift is detected, an alert or retraining is triggered before resuming monitoring.
Execution Sample
MLOps
def detect_drift(old_data, new_data, threshold=0.1):
    drift_score = calculate_statistical_distance(old_data, new_data)
    if drift_score > threshold:
        return True
    return False
This function compares old and new data using a statistical distance and returns True if drift is detected above a threshold.
Process Table
StepActionOld Data SummaryNew Data SummaryDrift ScoreDrift DetectedNext Step
1Collect new data batchMean=50, Std=5Mean=52, Std=50.04NoContinue Monitoring
2Collect new data batchMean=50, Std=5Mean=55, Std=60.12YesTrigger Alert
3Retrain modelModel updated with new data---Resume Monitoring
4Collect new data batchMean=55, Std=6Mean=54, Std=60.02NoContinue Monitoring
💡 Monitoring continues until drift score exceeds threshold, then model update occurs and monitoring resumes.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4
old_data_summaryMean=50, Std=5Mean=50, Std=5Mean=50, Std=5Mean=55, Std=6Mean=55, Std=6
new_data_summary-Mean=52, Std=5Mean=55, Std=6-Mean=54, Std=6
drift_score-0.040.12-0.02
drift_detected-NoYes-No
Key Moments - 3 Insights
Why does the drift score sometimes increase even if the mean changes only slightly?
Because drift score measures statistical distance considering both mean and standard deviation, small changes in either can increase the score as shown in Step 2 of the execution_table.
What happens after drift is detected at Step 2?
The system triggers an alert and retrains the model with new data, updating old_data_summary as shown in Step 3 before resuming monitoring.
Why does monitoring continue after retraining the model?
Because concept drift can happen anytime, continuous monitoring ensures the model stays accurate, as shown by Step 4 where monitoring resumes with updated data.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at Step 2, what is the drift score and was drift detected?
ADrift score is 0.02 and drift detected is No
BDrift score is 0.12 and drift detected is Yes
CDrift score is 0.04 and drift detected is No
DDrift score is 0.12 and drift detected is No
💡 Hint
Check the 'Drift Score' and 'Drift Detected' columns at Step 2 in the execution_table.
At which step does the model get retrained according to the execution_table?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look for the action 'Retrain model' in the 'Action' column.
If the threshold was lowered to 0.03, at which step would drift be detected first?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Compare drift scores in the execution_table to the new threshold of 0.03.
Concept Snapshot
Concept Drift Detection:
- Continuously monitor new data against training data
- Calculate a drift metric (e.g., statistical distance)
- If drift metric > threshold, trigger alert or retrain
- Update model or pipeline accordingly
- Resume monitoring to catch future drifts
Full Transcript
Concept drift detection means watching new data over time to see if it changes from the data the model learned on. We collect new data batches and compare their statistics to the old data. We calculate a drift score that measures how different the new data is. If this score is above a set threshold, we say drift is detected. Then, we alert or retrain the model with new data to keep it accurate. After updating, we keep watching for more drift. This process helps models stay reliable as data changes.