0
0
MLOpsdevops~30 mins

Audit trails for model decisions in MLOps - Mini Project: Build & Apply

Choose your learning style9 modes available
Audit Trails for Model Decisions
📖 Scenario: You work in a team that builds machine learning models. Your team wants to keep a clear record of every decision the model makes. This helps to check and understand the model's behavior later, like keeping a diary of its choices.
🎯 Goal: Build a simple program that logs each model decision with details like input data, prediction, and timestamp. This log acts as an audit trail to track model decisions over time.
📋 What You'll Learn
Create a list to store audit trail entries
Add a configuration variable for the model name
Write a function to log decisions with input, prediction, and timestamp
Print the audit trail entries
💡 Why This Matters
🌍 Real World
Audit trails help teams track and review machine learning model decisions. This is important for debugging, compliance, and improving trust in AI systems.
💼 Career
Knowing how to implement audit trails is useful for roles in MLOps, data science, and software engineering where model transparency and accountability are required.
Progress0 / 4 steps
1
Create the audit trail list
Create a list called audit_trail that will hold all the model decision records.
MLOps
Need a hint?

Use square brackets [] to create an empty list named audit_trail.

2
Add model name configuration
Create a variable called model_name and set it to the string "SimpleClassifierV1".
MLOps
Need a hint?

Use an equals sign = to assign the string "SimpleClassifierV1" to model_name.

3
Write the logging function
Write a function called log_decision that takes input_data and prediction as parameters. Inside the function, import datetime, get the current time with datetime.datetime.now(), and append a dictionary with keys model, input, prediction, and timestamp to the audit_trail list.
MLOps
Need a hint?

Remember to import datetime inside the function and use audit_trail.append() to add the record.

4
Log a decision and print the audit trail
Call the log_decision function with input_data set to {"feature1": 5, "feature2": 3} and prediction set to "ClassA". Then print the audit_trail list.
MLOps
Need a hint?

The printed list should contain one dictionary with the model name, input data, prediction, and a timestamp starting with datetime.datetime.