機械学習
国際バカロレア · IB Diploma · Computer Science · HL トピック 4 5:26 英語ナレーション・英語+中文字幕 burning-in
章
Transcript
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 change their wording, it is retrained on new examples.
垃圾邮件换了措辞,就用新例子重新训练。
That is machine learning: patterns from data, not rules from a programmer.
这就是机器学习:从数据中找规律,而不是由程序员写规则。
Artificial intelligence is the wide field of making computers do tasks that seem to need human intelligence.
人工智能是一个广阔的领域,研究让计算机完成看似需要人类智能的任务。
Machine learning is one part of it: learning from data.
机器学习是其中一部分:从数据中学习。
Deep learning is a kind of machine learning that uses neural networks with many layers.
深度学习是机器学习的一种,使用多层的神经网络。
Supervised learning uses labelled data, inputs with the right answers.
监督学习使用带标签的数据,也就是带正确答案的输入。
It classifies, like spam or not, or predicts a number, like a house price.
它可以分类,比如是否垃圾邮件,也可以预测数值,比如房价。
Unsupervised learning finds groups in unlabelled data, like shoppers with similar habits.
无监督学习在无标签数据中找分组,比如习惯相似的顾客。
Reinforcement learning learns actions from rewards and penalties, like a robot learning to walk.
强化学习通过奖励和惩罚学会行动,比如学走路的机器人。
Collect and label the data, then split it.
收集数据并加标签,然后拆分。
Most is used to train the model; the rest is held back as test data.
大部分用来训练模型,其余留作测试数据。
Testing on unseen data shows whether the model learned the general pattern.
用没见过的数据测试,才能看出模型是否学到了一般规律。
A model that memorises its training data but fails on new data is overfitting.
记住训练数据却在新数据上失败的模型就是过拟合。
Accuracy is the share of correct predictions.
准确率是预测正确的比例。
But a disease affects ten per cent of patients.
但某种疾病只影响百分之十的病人。
A model that always answers healthy is right ninety times in a hundred, so it scores ninety per cent, and finds no one who is ill.
一个永远回答“健康”的模型,一百次里对九十次,准确率百分之九十,却一个病人也找不出来。
With unbalanced classes, check each class, not just the total.
类别不平衡时,要看每一类的表现,而不只是总数。
Training repeats the same arithmetic on huge amounts of data, so it runs on GPUs and special chips with thousands of cores in parallel, often rented in the cloud.
训练要对海量数据反复做同样的运算,所以用 GPU 和专用芯片,成千上万个核心并行工作,常常在云端租用。
Using a trained model, called inference, needs far less power and can run on a phone.
使用训练好的模型,叫做推理,需要的算力少得多,在手机上就能运行。
If training data under-represents a group, the model works worse for them, as with face recognition on darker skin.
如果训练数据中某个群体太少,模型对他们就效果更差,比如人脸识别对深肤色的人。
If no one can explain a decision, a loan may be refused with no reason.
如果没人能解释决定,贷款可能被拒却没有理由。
It can be unclear who is responsible for harm.
造成伤害时,可能说不清该由谁负责。
And personal data may be used without consent.
个人数据也可能未经同意被使用。
Harm can be reduced.
伤害是可以减少的。
Train on data that represents everyone the model affects, and test accuracy separately for each group.
用能代表所有受影响者的数据训练,并分别测试每个群体的准确率。
Keep a human in the loop for serious decisions.
重大决定要有人参与。
Collect data with consent, and explain decisions to the people affected.
收集数据要征得同意,并向受影响的人解释决定。
Real data is messy.
真实数据很乱。
Cleaning fixes or removes wrong values, like an age of two hundred and fifty.
清洗修正或删除错误的值,比如二百五十岁的年龄。
Encoding turns categories into numbers.
编码把类别变成数字。
Normalisation puts features on a similar range, so income does not swamp age.
归一化让各特征处在相近的范围,收入就不会压倒年龄。
Feature selection keeps only inputs that help, so a student's ID number is dropped.
特征选择只保留有用的输入,所以学号要去掉。
Watch for data leakage: a feature that would not be known when the prediction is made.
要警惕数据泄漏:使用了在预测时还不可能知道的特征。
Using days in hospital to predict whether a patient will be admitted makes the model look excellent in testing.
用住院天数来预测病人是否会住院,测试时模型看起来非常好。
In real use that number does not exist yet, so the model fails.
但实际使用时这个数字还不存在,模型就失败了。
Linear regression fits the straight line that best matches the data.
线性回归拟合与数据最吻合的直线。
For five students' revision hours and scores, the line is y equals five point six x plus forty-six point two.
对五名学生的复习时间和成绩,这条直线是 y 等于五点六 x 加四十六点二。
For six hours, that predicts seventy-nine point eight, about eighty.
复习六小时,预测成绩七十九点八,约八十分。
Predicting far outside the data is unreliable.
在数据范围以外很远处预测是不可靠的。
k-nearest neighbours classifies a new point by its closest training points.
k 近邻算法根据最近的训练点给新点分类。
The single nearest point is a B, so with k equal to one the new point is B.
离它最近的一个点是 B,所以 k 等于一时新点是 B。
But its three nearest are one B and two As, so with k equal to three it is classed A.
但最近的三个点是一个 B 和两个 A,所以 k 等于三时它被分为 A。
A decision tree asks a sequence of yes or no questions, such as is the e-mail from a known contact, and ends at a leaf that gives the class.
决策树提出一串是非问题,比如这封邮件是否来自已知联系人,最后到达给出类别的叶子,容易解释。
It is easy to explain. K-means clustering is unsupervised: choose k centres, put each item with its nearest centre, move each centre to the mean of its cluster, and repeat until nothing changes.
k 均值聚类是无监督的:选 k 个中心,把每个数据归到最近的中心,再把中心移到该簇的平均位置,重复直到不再变化。
A neural network is made of layers of simple nodes.
神经网络由一层层简单的节点组成。
Pixel values enter the input layer, pass through a hidden layer, and the output layer gives cat or dog.
像素值进入输入层,经过隐藏层,输出层给出“猫”或“狗”。
Training compares the output with the right answer and adjusts every weight a little, over many thousands of examples.
训练时把输出和正确答案比较,把每个权重调整一点点,重复成千上万个例子。
Compare predictions with reality in a confusion matrix.
用混淆矩阵把预测和实际对比。
Accuracy is eighty-nine per cent.
准确率是百分之八十九。
Precision asks, of those we flagged, how many were right: four out of fourteen, about nought point two nine.
精确率问:标出来的里面有多少是对的? 十四个里四个,约零点二九。
Recall asks, of the real positives, how many did we find: four out of five.
召回率问:真正的阳性里找到了多少? 五个里四个。
A disease screen wants high recall; a spam filter wants high precision.
疾病筛查要高召回率,垃圾邮件过滤要高精确率。
Try these. Explain why test data is kept separate. Say why ninety-eight per cent accuracy can be useless. Then predict a score from the line, and work out precision and recall.
试试这些:解释为什么要单独保留测试数据;说明百分之九十八的准确率为什么可能没用;再用直线预测分数,并算出精确率和召回率。
In the exam, name the type of learning from the data.
考试时,根据数据说出学习类型。
Say why test data is kept separate.
说明为什么要单独保留测试数据。
Do not trust accuracy alone when the classes are unbalanced.
类别不平衡时不要只看准确率。
In ethics answers, name the issue, explain the harm in the scenario, and give a specific fix.
伦理题要说出问题,结合情境解释危害,再给出具体的改进办法。