0
0
MLOpsdevops~20 mins

Trigger-based retraining (schedule, drift, performance) in MLOps - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Trigger-based Retraining Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Identify models scheduled for retraining this week

Given a table model_retraining_schedule with columns model_id, retrain_day (day of week), and last_retrained (date), write a query to find all models scheduled for retraining on the current day.

MLOps
SELECT model_id FROM model_retraining_schedule WHERE retrain_day = TO_CHAR(CURRENT_DATE, 'FMDay');
ASELECT model_id FROM model_retraining_schedule WHERE retrain_day = CURRENT_DATE;
BSELECT model_id FROM model_retraining_schedule WHERE retrain_day = EXTRACT(DOW FROM CURRENT_DATE);
CSELECT model_id FROM model_retraining_schedule WHERE retrain_day = DAYNAME(CURRENT_DATE);
DSELECT model_id FROM model_retraining_schedule WHERE retrain_day = TO_CHAR(CURRENT_DATE, 'FMDay');
Attempts:
2 left
💡 Hint

Use a function that returns the day name as text matching the retrain_day format.

query_result
intermediate
2:00remaining
Detect models with data drift exceeding threshold

Given a table model_performance with columns model_id, drift_score (float), and evaluation_date, write a query to find models with a drift_score greater than 0.3 in the last 7 days.

MLOps
SELECT DISTINCT model_id FROM model_performance WHERE drift_score > 0.3 AND evaluation_date >= CURRENT_DATE - INTERVAL '7 days';
ASELECT model_id FROM model_performance WHERE drift_score >= 0.3 AND evaluation_date > CURRENT_DATE - 7;
BSELECT DISTINCT model_id FROM model_performance WHERE drift_score > 0.3 AND evaluation_date >= CURRENT_DATE - INTERVAL '7 days';
CSELECT model_id FROM model_performance WHERE drift_score > 0.3 AND evaluation_date BETWEEN CURRENT_DATE - 7 AND CURRENT_DATE;
DSELECT DISTINCT model_id FROM model_performance WHERE drift_score > 0.3 AND evaluation_date > CURRENT_DATE - INTERVAL '7 days';
Attempts:
2 left
💡 Hint

Use interval syntax to subtract 7 days from current date and include all models with drift_score strictly greater than 0.3.

schema
advanced
3:00remaining
Design a table to track retraining triggers

You need to design a table to store retraining triggers for ML models. Each trigger can be based on schedule, data drift, or performance drop. Which schema design best supports flexible trigger types and efficient querying?

ACREATE TABLE retraining_triggers (trigger_id SERIAL PRIMARY KEY, model_id INT, trigger_type VARCHAR(20), threshold JSONB, last_triggered TIMESTAMP);
BCREATE TABLE retraining_triggers (model_id INT PRIMARY KEY, schedule_day VARCHAR(10), drift_threshold FLOAT, performance_threshold FLOAT);
CCREATE TABLE retraining_triggers (trigger_id SERIAL PRIMARY KEY, model_id INT, schedule_day VARCHAR(10), drift_threshold FLOAT, performance_threshold FLOAT);
DCREATE TABLE retraining_triggers (trigger_id SERIAL PRIMARY KEY, model_id INT, trigger_type VARCHAR(20), threshold FLOAT, last_triggered TIMESTAMP);
Attempts:
2 left
💡 Hint

Consider flexibility to store different threshold types per trigger and efficient querying.

optimization
advanced
3:00remaining
Optimize query for recent performance drops

Given a large model_performance table with millions of rows, which index will best optimize this query?

SELECT model_id FROM model_performance WHERE performance_metric < 0.7 AND evaluation_date > CURRENT_DATE - INTERVAL '30 days';
ACREATE INDEX idx_date_perf ON model_performance(evaluation_date, performance_metric);
BCREATE INDEX idx_eval_date ON model_performance(evaluation_date);
CCREATE INDEX idx_perf_date ON model_performance(performance_metric, evaluation_date);
DCREATE INDEX idx_perf_metric ON model_performance(performance_metric);
Attempts:
2 left
💡 Hint

Consider the order of columns in a composite index matching the query filters.

🔧 Debug
expert
3:00remaining
Identify error in retraining trigger query

Consider this query to find models needing retraining due to performance drop:

SELECT model_id FROM model_performance WHERE performance_metric < 0.8 AND evaluation_date > CURRENT_DATE - 7;

What error or issue will this query cause?

ATypeError because performance_metric is compared to a string
BReturns no rows because CURRENT_DATE - 7 is invalid date arithmetic
CSyntaxError due to missing INTERVAL keyword in date subtraction
DCorrect query with no errors
Attempts:
2 left
💡 Hint

Check how date arithmetic is done in SQL standard.