0
0
MLOpsdevops~30 mins

Trigger-based retraining (schedule, drift, performance) in MLOps - Mini Project: Build & Apply

Choose your learning style9 modes available
Trigger-based Retraining for ML Models
📖 Scenario: You work as a machine learning engineer. You want to keep your ML model fresh and accurate. To do this, you will create a simple program that decides when to retrain the model. Retraining can happen on a schedule, when data changes a lot (data drift), or when model performance drops.
🎯 Goal: Build a Python program that tracks model retraining triggers: a fixed schedule, data drift detection, and performance drop detection. The program will decide if retraining is needed based on these triggers.
📋 What You'll Learn
Create a dictionary with last retrain date and current date
Add threshold values for data drift and performance drop
Write logic to check if retraining is needed based on schedule, drift, or performance
Print the retraining decision
💡 Why This Matters
🌍 Real World
ML models can lose accuracy over time. This project shows how to decide when to retrain models based on time, data changes, or performance drops.
💼 Career
Understanding retraining triggers is key for ML engineers and MLOps specialists to keep models reliable and efficient in production.
Progress0 / 4 steps
1
Setup retraining dates
Create a dictionary called dates with keys 'last_retrain' and 'current_date'. Set 'last_retrain' to the string '2024-04-01' and 'current_date' to the string '2024-04-15'.
MLOps
Need a hint?

Use a dictionary with exact keys and string dates as values.

2
Add retraining thresholds
Add two variables: drift_threshold set to 0.3 and performance_threshold set to 0.75.
MLOps
Need a hint?

Use simple float variables for thresholds.

3
Check retraining triggers
Write code to check if retraining is needed. Create a variable needs_retrain that is true if any of these are true: 14 or more days have passed between dates['last_retrain'] and dates['current_date'], data_drift is greater than drift_threshold, or model_performance is less than performance_threshold. Use data_drift = 0.35 and model_performance = 0.8 in your code.
MLOps
Need a hint?

Use datetime to calculate days passed. Combine conditions with or.

4
Print retraining decision
Write a print statement that outputs exactly "Retrain model: true" using the needs_retrain variable.
MLOps
Need a hint?

Use an f-string to print the message with the variable.