Data models and responsible machine learning
Introduced
3:21
Machine learning
A spam filter is not given a list of rules. Instead it is shown thousands of e-mails labelled spam or not spam, and finds the patterns itself. When spammers…
English narration · English and 中文 subtitles you can switch
In this lesson
| English | Meaning |
|---|---|
| training data/ˈtreɪnɪŋ ˈdeɪtə/ | The examples used to fit a machine-learning model's parameters or decision rules. |
| machine learning/məˈʃiːn ˈlɜːnɪŋ/ | Methods that use data to fit models for making predictions or identifying patterns. |
| supervised learning/ˈsuːpəvaɪzd ˈlɜːnɪŋ/ | Learning a model from examples supplied with target answers or labels. |
| confusion matrix/kənˈfjuːʒn ˈmeɪtrɪks/ | |
| precision/prɪˈsɪʒn/ | in classification, the fraction of predicted positives that are truly positive |
| recall/ˈriːkɔːl/ | True positives divided by all actual positives, when that denominator is nonzero. |
A hiring model that learned a bias, 2018
- In 2018 Reuters reported that Amazon had abandoned an experimental tool for rating job applicants. It had learned from ten years of past résumés, most from men, and began to mark down résumés containing the word "women's", as in "women's chess club captain".
- The model was doing exactly what it was trained to do: copy patterns in its training data 训练数据. Machine learning 机器学习 finds patterns in data; it does not know which patterns are fair.
Why did Amazon's experimental tool mark down some résumés?
Difficulty 1/5 · 100 coins + a small bonus on first completion today
It copied patterns in its training data.
Kinds of learning
- Supervised learning 监督学习: labelled examples (email → spam or not). Unsupervised: find groups without labels. Reinforcement: learn from rewards.
- Training data teaches; separate test data checks performance on new cases.
Match each task to a kind of learning.
Difficulty 2/5 · 140 coins + a small bonus on first completion today
Labels, groups, rewards.
Accuracy can mislead
- If 90 of 100 cases are the majority class, a model that always predicts "majority" scores 90% accuracy and finds none of the minority.
- Use a confusion matrix 混淆矩阵: true and false positives and negatives.
90 of 100 cases are the majority class. What accuracy (%) does a model get by always predicting the majority?
Difficulty 2/5 · 140 coins + a small bonus on first completion today
It finds none of the minority.
Precision and recall
- Precision 精确率 = TP ÷ (TP + FP): of the cases flagged, how many were right.
- Recall 召回率 = TP ÷ (TP + FN): of the real cases, how many were found.
Accuracy and class balance
Compare overall accuracy, per-class recall and positive precision. Different denominators answer different questions, and class balance affects overall accuracy.
What does recall measure?
Difficulty 1/5 · 100 coins + a small bonus on first completion today
TP ÷ (TP + FN).
Worked example: a fraud detector
Test set: 1,000 transactions, 20 frauds. The model flags 25; 15 of them are fraud.
- TP = 15, FP = 10, FN = 5, TN = 970.
- Accuracy = (15 + 970) ÷ 1,000 = 98.5%. Precision 精确率 = 15 ÷ 25 = 60%. Recall = 15 ÷ 20 = 75%.
- Judgement: 98.5% sounds excellent, but a quarter of frauds are missed and 40% of alerts are false. Whether that is acceptable depends on the cost of each error.
A model finds 30 of 40 real cases and makes 20 false alarms. What is its precision in %?
Difficulty 2/5 · 140 coins + a small bonus on first completion today
30 ÷ (30 + 20) = 60%.
Responsible use
- Check training data 训练数据 for under-represented groups; test performance separately for each group.
- Overfitting: a model that memorises training data performs badly on new data.
An overfitted model performs well on new data.
Difficulty 1/5 · 100 coins + a small bonus on first completion today
It memorises training data.
High accuracy does not mean a fair or useful model. With imbalanced classes, report precision 精确率 and recall, and check whether errors fall unfairly on one group.
A model with 98% accuracy must be fair.
Difficulty 1/5 · 100 coins + a small bonus on first completion today
Check errors by group.
Machine learning 机器学习 copies patterns in training data, including biased ones. Test on unseen data, use a confusion matrix, report precision and recall as well as accuracy, and check errors group by group.
A school proposes a model to predict which students will fail. Explain two risks and how you would test the model responsibly.
Data, errors, testing.
What went wrong? Only the site team sees this.