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ː ˈɑː/ | การจดจำตัวอักษรด้วยแสง |
| 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. |
การทำนายตัวเลข ไม่ใช่ชื่อ
- ถามโมเดลว่า "อีเมลนี้คือสแปมหรือไม่?" มันต้องเลือกจากชุดคำตอบที่กำหนดไว้ถามว่า "บ้านหลังนี้จะขายได้ในราคาเท่าไหร่?" ไม่มีชุดคำตอบให้เลือก: คำตอบคือตัวเลข และการคลาดเคลื่อนไปพันปอนด์ก็ถือว่าใกล้เคียงถูกต้องแล้ว
- Those are two different tasks, and mixing them up is the commonest mistake in this topic. Both are supervised learning; only the shape of the answer differs.
- บทเรียนนี้เกี่ยวกับ regression เทียบกับ classification, วิธีที่ linear regression เลือกเส้นตรงของมัน, และวิธีผลิตภัณฑ์จริงเชื่อมต่อกันโมเดลที่ถูกฝึกเข้าเป็น pipeline
Regression และ Classification
- Classification ทำนาย category จากชุดที่กำหนดไว้: แมวหรือสุนัข, สแปมหรือไม่สแปม, ตัวเลขสิบตัวใดตัวหนึ่ง
- Regression ทำนาย number บนสเกลต่อเนื่อง: ราคาบ้าน, อุณหภูมิพรุ่งนี้, เวลาที่ใช้ในการเดินทางจะนานเท่าไร
- ทั้งคู่เป็น supervised: ทั้งคู่เรียนรู้จากตัวอย่างที่มีป้ายกำกับ การตัดสินใจระหว่างทั้งสองขึ้นอยู่กับคำถามข้อเดียว: คำตอบเป็น label หรือตัวเลข?
- ความแตกต่างนี้เปลี่ยนวิธีการวัดความสำเร็จ ตัวจำแนกประเภท (classifier) จะถูกหรือผิด; ส่วนตัวทำนายค่า (regressor) จะมีค่าความคลาดเคลื่อนเป็นระยะทางหนึ่ง ดังนั้นฟังก์ชันความสูญเสีย (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.
ตัวอย่างคำอธิบาย: งานไหนเป็นแบบไหน
- การทำนายว่าลูกค้าคนนั้นอยู่ในกลุ่มประเภทใดในห้าประเภท. Classification: คำตอบเป็นหนึ่งในชุด category ที่กำหนดไว้
- การทำนายว่าลูกค้าคนนั้นจะใช้จ่ายกี่บาทในเดือนหน้า. Regression: คำตอบคือตัวเลข และการอยู่ใกล้ๆ ถือว่าเกือบถูกต้อง
- การทำนายว่าเครื่องจักรจะล้มเหลวในสัปดาห์หน้าหรือไม่. Classification: ใช่หรือไม่ใช่ การทำนายว่าจะใช้เวลากี่วันจนเครื่องจักรล้มเหลว. Regression
- ข้อมูลพื้นฐานเดียวกันสามารถนำไปใช้ได้ทั้งสองแบบ อ่าน คำถาม ที่ถูกถาม อย่าอ่านเฉพาะเนื้อหา
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
- Linear regression พยายามสร้างเส้นตรง หรือพื้นราบเมื่อมี inputs หลายตัว:
- ค่าสัมประสิทธิ์ถูกเลือกเพื่อ ลดผลรวมของความผิดพลาดยกกำลังสอง ระหว่างค่าทำนายของเส้นตรงกับค่าจริงในชุดฝึกสอน
- ยกกำลังสอง ด้วยเหตุผลสองประการที่ข้อสอบยอมรับ: ความผิดพลาดด้านบนและด้านล่างของเส้นจะไม่หักล้างกัน และความผิดพลาดขนาดใหญ่จะถูกปรับหนักมากกว่าความผิดพลาดขนาดเล็กหลายอย่าง

เส้นที่เหลือระยะทางยกกำลังสองรวมน้อยที่สุด
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.
เมื่อเส้นตรงเป็นโมเดลที่เหมาะสม
- ใช้ linear regression เมื่อความสัมพันธ์ดู เป็นเส้นตรงโดยประมาณ และคุณต้องการโมเดลที่มนุษย์อ่านเข้าใจ: แต่ละ coefficient บอกว่า input นั้นมีความสำคัญมากแค่ไหน และเป็นไปในทิศทางใด
- เมื่อข้อมูลมีรูปโค้ง หลักการเดียวกันยังใช้ได้กับโมเดลอื่น: polynomial regression, decision tree, หรือ neural network ในทุกกรณีสูตรคือเหมือนกัน เลือกโมเดล, กำหนด loss, ลดค่ามันลง
- สูตรนี้คือสิ่งที่เชื่อมโยงบทเรียนนี้เข้ากับบทก่อนหน้า: Gradient descent ก็คือวิธีการลดค่าเมื่อไม่มีสูตรสำหรับคำตอบ

AI ในผลิตภัณฑ์จริง
- ระบบจริงมักไม่ใช้โมเดลเดียว พวกเขาเชื่อมต่อกันหลายโมเดลที่ถูกฝึกเข้าเป็น pipeline โดยแต่ละส่วนทำหน้าที่ขั้นตอนหนึ่ง
- การระบุใบหน้าที่ประตู: กล้องจับภาพใบหน้า, การจดจำภาพแปลงมันเป็นตัวแทนเชิงตัวเลข, และนำมันไปเทียบกับตัวแทนของผู้ที่ลงทะเบียนไว้
- การอ่านป้ายเสียงดังสำหรับผู้เดินทาง: การจดจำภาพระบุตำแหน่งข้อความ, OCR แปลงพิกเซลเป็นตัวอักษร, Machine translation แปลคำศัพท์, และ 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.
ตัวอย่างคำอธิบาย: การฝึก vs การอนุมาน
- แอปพลิเคชันบนโทรศัพท์จดจำพืชจากรูปถ่ายได้ทันที แต่การฝึกโมเดลใช้เวลาถึงสัปดาห์บนเครื่องคอมพิวเตอร์จำนวนมาก อธิบายเหตุผล.
- Training รัน forward และ backward passes ซ้ำๆ บนชุดข้อมูลที่มีป้ายกำกับขนาดใหญ่มาก ปรับ millions of weights ผ่านหลาย epochs นั่นคือสิ่งที่ใช้เวลาถึงสัปดาห์
- การอนุมาน (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.
คะแนนที่หลุดหายไป
- การจำแนกประเภทให้ผลลัพธ์เป็นหมวดหมู่, การถดถอยให้ผลลัพธ์เป็นตัวเลข ทั้งสองแบบใช้การเรียนรู้แบบมีผู้สอน; นั่นไม่ใช่ความแตกต่าง
- การถดถอยเชิงเส้นลดค่า ผลรวมของข้อผิดพลาดกำลังสอง, ไม่ใช่ "ระยะทางรวม" ให้ระบุคำว่า "กำลังสอง" และอธิบายเหตุผล
- คำตอบของกระบวนการทำงานต้องระบุขั้นตอนตาม ลำดับ และบอกสิ่งที่แต่ละขั้นตอนส่งต่อไปยังขั้นตอนถัดไป
- การฝึก คือการส่งผ่านข้อมูลไปข้างหน้าและย้อนกลับซ้ำหลายครั้ง; การอนุมาน คือการส่งผ่านข้อมูลไปข้างหน้าเพียงครั้งเดียว อย่าอธิบายการฝึกเมื่อคำถามถามถึงการใช้งานจริง
คุณเข้าใจแล้ว
- การจำแนกประเภท ทำนายหมวดหมู่, การทำนายค่า ทำนายตัวเลข; ทั้งสองแบบใช้ข้อมูลที่มีป้ายกำกับ (supervised), และรูปแบบคำตอบของคำถามจะกำหนดว่าควรใช้วิธีใด
- การถดถอยเชิงเส้น ปรับ $y = m_1x_1 + \ldots + c$ โดย ลดค่าผลรวมของข้อผิดพลาดกำลังสอง ดังนั้นข้อผิดพลาดจึงไม่สามารถหักล้างกันได้ และข้อผิดพลาดขนาดใหญ่จะถูกปรับหนัก
- ข้อมูลที่มีรูปแบบโค้งต้องการโมเดลอื่น แต่สูตรการเลือกโมเดลไม่เปลี่ยน: เลือกโมเดล, กำหนดฟังก์ชันความสูญเสีย, ลดค่ามันลง
- ผลิตภัณฑ์จริง เชื่อมโยง โมเดลเข้าด้วยกัน: การจดจำภาพ, OCR, การแปล และการแปลงข้อความเป็นเสียง; การฝึก คือการส่งผ่านข้อมูลไปข้างหน้าและย้อนกลับหลายครั้ง, การอนุมาน คือการส่งผ่านข้อมูลไปข้างหน้าเพียงครั้งเดียว
เกิดปัญหาอะไรขึ้น? เฉพาะทีมเว็บไซต์เท่านั้นที่เห็นข้อมูลนี้
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