Coordinates, slopes and reading a chart
Points on all four sides of zero, slope as rise over run, y = m × x + b, and honest charts.
Why it matters
Every chart in this course is points placed on two axes: a loss curve falling as a model trains, a scatter of customers, a line a model fits through data. Reading one well means knowing where each point sits, what the slope of a line says, and how a chart can mislead you. Slope matters far beyond charts, too: "how much does this change when that changes?" is the question behind every rate, every trend and, in Phase 2, every derivative. This lesson builds the skill with numbers first and pictures second.
What you'll be able to do
- Place points on all four sides of zero from their (x, y) coordinates
- Work out a slope as rise over run, and say what its sign and size mean
- Read y = m × x + b as a line, with a slope and a starting value
- Read a chart critically: axes, units, where the axis starts, and how far a trend can be stretched
What it covers
- Two numbers place a point
- Slope: rise over run
- Follow the trend
- Lines: y = m × x + b
- Reading a chart without being fooled
- Count the points in each quadrant
- Graphs in AI
Show the answer
3 right of the center, 2 below it
The first number is across (x) and the second is up or down (y). So (3, −2) is 3 to the right of the center and, being negative, 2 below it.
Two numbers place a point
A chart has two number lines that cross at zero. The across one is the x-axis and the up-and-down one is the y-axis; where they cross is the origin, (0, 0). Any point is two numbers in a fixed order, (x, y): first how far across, then how far up. The order matters: (2, 5) and (5, 2) are different points. A map works the same way, with longitude across and latitude up, and mixing them up puts a store in the wrong country.
Negative numbers carry on past zero, just as on the number line: negative x is left of the origin and negative y is below it. The axes split the page into four regions, called quadrants:
| blank | x is positive | x is negative |
|---|---|---|
| y is positive | top right: (3, 2) | top left: (−3, 2) |
| y is negative | bottom right: (3, −2) | bottom left: (−3, −2) |
In Python, a point is often kept as a pair of numbers in brackets, (3, -2), and a set of points as a list of pairs:
points = [(3, 2), (-3, 2), (3, -2), (-3, -2)] for x, y in points: print("across", x, "and up", y)
Show the answer
(−4, −1)
Bottom left means left of the origin (negative x) and below it (negative y): (−4, −1).
Slope: rise over run
The slope of a line says how steep it is: how far it goes up for each step across. Between two points, it's the rise (the change in y) divided by the run (the change in x):
slope = (y₂ − y₁) ÷ (x₂ − x₁)
x1, y1 = 1, 3 x2, y2 = 4, 9 slope = (y2 - y1) / (x2 - x1) print(slope) # up 6 over 3 steps: 2.0 per step
The sign tells you the direction. A positive slope rises from left to right, a negative slope falls, and a slope of 0 is flat. The size tells you how fast: a slope of 2 rises twice as fast as a slope of 1. Slopes have units, too: if x is days and y is dollars, a slope of 50 means $50 more each day.
The slope between two points far apart is an average rate. Sales that rose $250 over five days rose $50 a day on average, even if most of it came on one busy day. A straight line has the same slope everywhere; a curve has a different slope at each point, and measuring that is exactly what a derivative does in Phase 2.
slope = (400 - 150) / (7 - 2) print(slope)
Show the answer
50.0
Rise over run: sales rose by 250 over 5 days, which is 50.0 dollars a day.
Follow the trend
A newsletter had 1,200 subscribers in week 3 and 1,800 in week 8. Set slope to the subscribers gained per week, then week_12 to the number expected in week 12 if the trend continues: start from week 8 and add the slope for each of the 4 weeks.
week_a, subs_a = 3, 1200 week_b, subs_b = 8, 1800 slope = 0 week_12 = 0 print(slope, week_12)
Lines: y = m × x + b
Any straight line can be written as y = m × x + b. The m is the slope, and b is where the line crosses the y-axis, the value of y when x is 0, called the intercept. It's the formula from the formulas lesson, and the neuron's y = w × x + b with different letters.
Reading a line's formula tells you its shape at once. y = 3x + 5 starts at 5 and climbs 3 for every step across. y = −2x + 4 starts at 4 and falls 2 for every step, so it crosses zero at x = 2. A formula and a chart are two views of the same line, and you can work out one from the other.
To find the formula from two points, get the slope from rise over run, then use either point to find b, because b = y − m × x. Through (1, 3) and (4, 9), the slope is 2, so b = 3 − 2 × 1 = 1, and the line is y = 2x + 1. Checking with the other point: 2 × 4 + 1 = 9. It works.
The curve is y = m × x + b drawn across the whole x range. Change m to tilt it, and b to slide it up and down.
Show the answer
At y = 5, where x is 0
The y-axis is where x = 0, and there y = 3 × 0 + 5 = 5. That's the intercept, b.
Show the answer
It goes down by 6
The slope is the change in y per step of x: −3 per step, so 2 steps change y by −6.
Reading a chart without being fooled
Before trusting a chart, check four things:
- The axes and units. What's across, what's up, and in what units? A chart with no units can't be read.
- Where the y-axis starts. Starting it just below the data makes a 2% change fill the picture. Bars should start at zero.
- The scale. On a log scale, each step up is ten times the last, so a straight line means steady growth by a percentage, not by an amount.
- How far the trend is stretched. A line through ten weeks of data says little about week 100, because growth that looks steady over a short stretch rarely stays steady for long.
These questions take seconds, and they catch most misleading charts, including the ones you make yourself.
One more caution: two lines that rise together don't show that one causes the other. Ice-cream sales and sunburns climb together every summer because both follow the weather. A chart can show that things move together; it takes more careful work, like the experiments in Phase 2, to show that one thing causes another.
Count the points in each quadrant
Count how many of the points fall in each quadrant. Set top_right, top_left, bottom_left and bottom_right. (None of these points sits on an axis.)
points = [(3, 2), (-1, 4), (-2, -5), (6, -1), (2, 7)] top_right = 0 top_left = 0 bottom_left = 0 bottom_right = 0 # loop over the points and count each one in its quadrant print(top_right, top_left, bottom_left, bottom_right)
Graphs in AI
You'll read these charts constantly. A loss curve plots training steps across and the loss up; its slope shows how fast the model is learning, and a flattening curve means each step helps less than before. A scatter of predictions against true values shows a good model's points hugging the line y = x. A classifier's decision boundary is a line, or a curve, splitting the chart into two regions. And in Phase 1 you'll see words placed as points, where nearby points mean similar meanings.
x = -4 print(2 * x + 3)
Show the answer
-5
2 × −4 = −8, and −8 + 3 = −5. So the point (−4, −5) is on the line, in the bottom-left quadrant.
Show the answer
Each step is improving the model less than before
A flatter curve has a smaller slope: the loss still changes, but by less each step. It often means training is close to as good as it will get.
Practice what you just read
- 2 code examples you can edit and run
- a practice exercise that checks your code
- a 6-question quiz
- 5 review cards for spaced repetition
Try a quiz question
Which point is in the top-left quadrant?