Machine LearningLesson 22 of 22

Ethics, Bias and Responsible Deployment

Models copy the past. If hiring data is biased, the model will be biased. Ethics is not an afterthought, it is part of building a system that works for everyone.

Models copy the past. If hiring data is biased, the model will be biased. Ethics is not an afterthought, it is part of building a system that works for everyone.

You need to check performance by group, not just overall. A model can be 95% accurate overall but 50% for a minority group. This is how real products fail and harm.

Responsible deployment means monitoring, not just launching. Data drifts, and a model that was good last month may be bad today. Plan to watch it.

Check bias

Slice metrics by group. Compare precision/recall for different demographics or regions. If a group is worse, collect more data or adjust thresholds.

PYTHON
from sklearn.metrics import classification_report
print(classification_report(y_test, pred, target_names=["groupA","groupB"]))
# Check per-group

Deployment and monitoring

Deploy with a canary, log predictions, and monitor drift. Have a rollback plan.

PYTHON
# Monitor: track p(y) over time
# If drift > threshold, retrain
# Keep human in the loop for high-stakes decisions

Syntax

PYTHON
# Check per-group metrics
for group in ["A","B"]:
    mask = df["group"]==group
    print(group, accuracy_score(y_test[mask], pred[mask]))

The EU AI Act trap

High-risk AI systems (hiring, credit) now need documentation and human oversight in the EU. Deploying without this can be illegal. Reddit r/MachineLearning top post explains why “just ship it” fails in 2024.

PYTHON
# Keep human in the loop for high-stakes decisions
# Log predictions and allow appeal

Good to know

  • Models copy past bias — check per-group metrics.
  • Overall accuracy hides minority failures.
  • Monitor drift and have a rollback plan.

Keep building your ML models

Copy the code, run it locally with pip install scikit-learn pandas, and continue to the next lesson.

→ Back to track