Regression and AI in practice
導入済み
13:04
AIとは何か
猫と犬を見分けるルールを誰一人として書いた者はいない。「耳が尖っているしひげがあるなら」という条件をプログラムで入力した程序员もいない。それでもあなたの電話はそれを認識する…
英語のナレーション・英語と中国語の字幕を切り替え可能
このレッスンの内容
| English | 意味 |
|---|---|
| model/ˈmɒdl/ | A simplified representation of a system used to explain, analyse or predict its behaviour. |
| supervised learning/ˈsuːpəvaɪzd ˈlɜːnɪŋ/ | A way of training a model using data with correct labels. |
| regression/rɪˈɡreʃn/ | 回帰 |
| classification/ˌklæsɪfɪˈkeɪʃn/ | 分類 |
| linear regression/ˈlɪnɪə rɪˈɡreʃn/ | 線形回帰 |
| pipeline/ˈpaɪplaɪn/ | An arrangement that overlaps stages of different instructions or tasks to improve overall throughput. |
| category/ˈkætɪɡəri/ | A group or class that an item can be assigned to. |
| labelled examples | Training examples that include both input data and the correct answers. |
| label/ˈleɪbl/ | A symbolic name identifying an item; in assembly language, a name associated with an instruction or storage address. |
| classifier | A model that predicts which category an input belongs to. |
| regressor | A model that predicts a number on a continuous scale. |
| loss functions | Methods for measuring how wrong a model's predictions are. |
| coefficients/ˌkəʊɪˈfɪʃənts/ | Numerical or constant factors multiplying terms in an expression. |
| sum of the squared errors | The total found by squaring each prediction error and adding the results. |
| training/ˈtreɪnɪŋ/ | The process of adjusting a network's weights and biases using data. |
| polynomial regression | A method that predicts numbers using powers of inputs to model curved relationships. |
| decision tree/dɪˈsɪʒn triː/ | A model that makes predictions by following a series of decisions. |
| neural network | A model made of connected units arranged in layers that learn patterns from data. |
| loss/lɒs/ | A measure of how wrong a model's predictions are. |
| gradient descent/ˈɡreɪdɪənt dɪˈsent/ | An iterative method that adjusts parameters in the direction opposite the gradient to seek a smaller value of an objective function. |
| Face identification | The process of finding a person's identity by comparing their face with known faces. |
| image recognition/ˈɪmɪdʒ ˌrekəɡˈnɪʃn/ | Computer processing that identifies or classifies objects, patterns or other features in images. |
| OCR/ˌəʊ siː ˈɑː/ | 光学文字認識(OCR) |
| pixels/ˈpɪkslz/ | An individual picture element in a digital image or display. |
| machine translation/məˈʃiːn trænˈsleɪʃn/ | Automatic conversion of text or speech from one human language into another. |
| text-to-speech/tekst tə spiːtʃ/ | Technology that changes written text into spoken audio. |
| inference/ˈɪnfərəns/ | The use of a trained model to make a prediction from new input. |
| forward and backward passes | Steps that produce a prediction, then work backwards to guide changes to weights. |
| labelled dataset | A collection of data examples with their correct answers included. |
| weights | Numbers that control how strongly inputs affect a network's outputs. |
| epochs/ˈiːpɒks/ | Complete passes through the training dataset, with each pass potentially divided into smaller batches. |
| network/ˈnetwɜːk/ | A set of connected devices or nodes that can exchange information. |
| activate | To apply a function to a network unit's input to produce its output. |
| layer/ˈleɪə/ | A group of units in a neural network at the same stage of processing. |
名前ではなく数を予測する
- モデルに「このメールはスパムか?」と聞けば、固定された選択肢の中から選ぶ必要がある。「この家はいくらで売れるか?」と聞けば、選ぶべき選択肢はない:答えは数であり、千ポンド外れていてもほぼ正解となる。
- これらは2つの異なるタスクであり、これらを混同することがこの分野における最も一般的なミスである。どちらも教師あり学習だが、答えの形状だけが異なる。
- このレッスンはregression(回帰)対classification(分類)、**linear regression(線形回帰)**がどのように直線を選ぶか、そして実製品がどのように学習済みモデルをパイプラインとしてつなげているかについてである。
回帰と分類
- **Classification(分類)は固定されたセットからcategory(カテゴリー)**を予測する:猫または犬、スパムまたは非スパム、10桁の数字のうちどれか。
- **Regression(回帰)は連続スケール上のnumber(数)**を予測する:家賃、明日の気温、旅にかかる時間など。
- 両方とも**supervised(教師あり)**である:どちらもラベル付きの例から学ぶ。両者の選択は一つの問いによって決定される:答えはラベルかそれとも数か?
- この区別は成功の測り方を変える。分類器は正解か誤答か;回帰器は特定の距離だけ外れているため、そのためにloss functions(損失関数)が異なる。

The difference between regression and classification is that regression predicts:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Regression outputs a continuous number (price, temperature); classification outputs a category.
Regression predicts a continuous number (a price, a temperature), while classification predicts a category (cat vs dog).
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Number out = regression; category out = classification — the two main kinds of supervised prediction.
演習例:どのタスクがどれか
- 買い物客が5種類の顧客タイプに属するかを予測する Classification:答えは固定されたカテゴリーの一つである。
- その買い物客が来月にいくだけ使うかを予測する Regression:答えは数であり、近い値であればほぼ正解とみなされる。
- 機械が来週中に故障するかを予測する Classification:はいまたはいいえ。 故障するまで何日後かを予測する Regression。
- 同じ基盤となるデータがどちらにも使われる。対象分野ではなく、問われている**question(質問)**を読むこと。
Match each prediction task to its kind.
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
The same data can feed either. Read the question: a label from a fixed set, or a number on a scale.
線形回帰
- **Linear regression(線形回帰)**は直線をfit(フィット)させる、あるいは複数の入力が存在する場合は平面をfitさせる:
- 係数は、直線の予測値と実際のトレーニング値との間の**二乗誤差和(sum of the squared errors)をminimise(最小化)**するために選ばれる。
- 二乗とする理由は、試験で認められる2つの理由がある:線上および線下のエラーが互いに打ち消し合えないこと、そして大きなエラーはいくつかの小さなエラーよりもはるかに厳しくペナルティされること。

総二乗距離が最も少ない直線

Fitting a regression line
Drag the controls. Linear regression draws the straight line that makes the squared distances to the data points as small as possible — then it predicts a number for any new input.
Linear regression chooses its coefficients to:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
It fits the line/hyperplane that makes the squared differences from the data points as small as possible.
Why does linear regression minimise the sum of the SQUARED errors rather than the errors themselves?
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Both reasons are accepted. Without squaring, a line could have a huge error above and below and still score zero.
直線が適切なモデルとなる場合
- 関係性が**roughly linear(おおよそ線形)**に見え、人間が読み取れるモデルを望む場合に線形回帰を用いる:各係数はその入力がどれだけ重要で、どの方向に影響するかを示す。
- データが曲がる場合でも、同じアイデアは異なるモデルで適用可能である:多項式回帰、意思決定木、あるいはニューラルネットワーク。どの場合でもレシピは同じ、モデルを選び、loss(損失)を定義し、それを最小化すること。
- そのレシピこそが、このレッスンを前回のレッスンに結びつけるものである:勾配降下法とは、答えに対する公式がない場合に最小化を行うための手法にすぎない。

実製品におけるAI
- 実システムは通常、1つのモデルだけを使うことはない。複数の学習済みモデルを**pipeline(パイプライン)**としてつなぎ、それぞれが1つの工程を行う。
- ドアでの顔認識:カメラが顔をキャッチし、画像認識がそれを数値表現に変換し、登録されている人物の表現と比較する。
- 旅行者のための看板読み上げ:画像認識がテキスト位置を特定し、OCRがピクセルを文字に変換し、機械翻訳が単語を変換し、**text-to-speech(音声合成)**がオーディオを生成する。
- 試験ではシナリオを与え、どのようなモデルが用いられ、順に説明を求められる。段階と、それが次の段階に提供する出力を名指しせよ。

Match each AI idea to what it means.
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
Training fits the model once; inference is the quick prediction each time a user interacts.
A "read a sign aloud" feature typically chains which models?
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Several trained models form a pipeline: find the text, extract characters, translate, then speak.
Put the stages of an app that reads a foreign sign aloud in order.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
Several trained models chained together, each handing its output to the next. Name the stage and what it produces.
演習例:トレーニング対推論
- スマートフォンアプリが写真から植物を瞬時に認識するが、モデルのトレーニングには多数のマシンで数週間かかった。なぜか説明せよ。
- **Training(トレーニング)**は非常に大きいラベル付きデータセットに対してフォワードおよびバックワードパスを反復的に実行し、多くのエポックにわたって数百万の重みを調整する。これが数週間かかったのである。
- 推論(Inference)とは、学習済みのモデルを用いて、重みが固定されたネットワークを単一の順伝播で通すことです:乗算、加算、活性化関数適用を層ごとに一度だけ行います。
- 知性は学習された重みに宿っているため、完成したモデルは小さく高速であり、携帯電話でも動作するようになります。

Using a trained model to make a prediction requires only a single ____ pass.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Training repeats forward and backward passes over a huge dataset; inference runs the fixed weights once, which is why it is instant.
見落としやすいポイント
- **分類(Classification)はカテゴリを出力し、回帰(Regression)は数値を出力します。**どちらも教師あり学習ですが、これが違いではありません。
- 線形回帰は「総距離」ではなく二乗誤差和を最小化します。「二乗」という言葉を使用し、その理由も述べてください。
- パイプラインの答えは、段階を順序立てて列挙し、各工程が次の工程に何を渡すかを説明する必要があります。
- **学習(Training)**は順伝播と逆伝播の繰り返しです。**推論(Inference)**は単一の順伝播のみです。使用について問われている場合、学習の説明は不要です。
理解できましたか
- **分類(classification)**はカテゴリを予測し、**回帰(regression)**は数値を予測します。どちらも教師あり学習であり、問題の答えの形式によってどちらを選ぶかが決まります。
- 線形回帰(linear regression)は$y = m_1x_1 + \ldots + c$を二乗誤差和を最小化することによってフィットするため、誤差が相殺されず、大きな誤差は強くペナルティとして課されます。
- 曲線のデータには別のモデルが必要ですが、手順は変わりません:モデルを選び、損失関数を定義し、それを最小化します。
- 実際の製品ではモデルを連鎖させます:画像認識、OCR(光学文字認識)、翻訳、音声合成などです。**学習(training)**は多数の順伝播・逆伝播であり、**推論(inference)**は単一の順伝播です。
何が問題でしたか?この内容はサイトの運営チームだけが確認します。
Try it in the lab 32
All labs →- Teach a Perceptron
- Train a Network on Your Drawings
- Teach a Robot by Reward
- Build a Decision Tree
- Nearest Neighbours
- Roll Down the Loss
- Find the Groups
- Find the Shortest Route
- See Like a Computer
- Guess the Next Word
- Is the Computer Fair?
- Build an Expert System
- Evolve a Catapult
- Catch the Spam
- Think Ahead
- Inside a Neural Network
- Learning or Remembering? Overfitting
- Search the Maze
- What Should I Watch? A Recommender
- Teach a Car to Drive
- Matchbox Learner
- Build a Chatbot
- Fewer Colours
- Mood Meter
- Spot the Fraud
- Hear the Word
- Follow the Ants
- Plan the Delivery Round
- Squash the Data
- Explore or Exploit? Learning by Trying
- Mark the Model
- Ask Many Models