☰ خطة العام · تكنولوجيا المعلومات والاتصالات (بالإنجليزية)

The straight-line model

الأسبوع 11 · الدرس ١ «التنبؤ باستخدام نموذج الذكاء الاصطناعي» (٢): النموذج الخطي ومعنى w وb والكود والتدريبات · 3 دروس
1

The straight-line model: y = w × x + b

ICT Prep 3 Term 1, Unit 2, Lesson 1: pp. 68–75
GoalWrite the straight-line model y = w × x + b and draw its line from invented points.
New words
linear model · a model whose output changes by the same amount for each step of the inputinput x · the value we give the modeloutput y · the value the model gives back: the expected resultequation · a statement with an equals sign that links the values
Explanation

Last week you made predictions from a table by looking for a pattern. The simplest pattern is a straight line: every time x grows by one step, y changes by the same amount. This is the linear model, written y = w × x + b. The input is x, the expected output is y, and w and b are two fixed numbers that describe the line. For hours of study and marks, the picture shows the line y = 10x + 40. With x = 2 hours we get y = 10 × 2 + 40 = 60 marks. In Python the model is one line: y = w * x + b. A linear model is simple, which makes it a good first example of how an AI model works. It is far from the only model, and many real problems need more complicated ones.

xy12345204060801000y = 10x + 40(0, 40)
Worked examples
ABCDE
1x (hours)0123
2y (marks)40506070
3change+10+10+10
The sheet lists four points of the line. Each hour adds 10 marks. At 0 hours the line starts at 40.
Python
1w = 10
2b = 40
3x = 2
4y = w * x + b
5print(y)
Output
60
Python can do the same calculation. With w = 10, b = 40 and x = 2 the line y = w * x + b stores 60 in y.
Class activity

Using y = 10x + 40, calculate y for x = 0, 1, 4 and 6 and write the answers in a table. Then draw the four points on squared paper and join them with a ruler. Do the points lie on a straight line?

Practice
1
What is y when x = 3 in y = 10x + 40?
2
What do x and y stand for in the model?
3
Which part of the model describes the line: x, y or w and b?
4
Is the linear model the only kind of AI model?