Section 1 - Instruction

Welcome to the lesson on linear regression! This technique helps us find a straight-line pattern between two sets of numbers.

For example, if you have a list of people's heights and their shoe sizes, linear regression finds the line that best connects these pairs so you can predict one from the other.

Engagement Message

Can you think of two numbers in your life that seem to change together?

Section 2 - Instruction

Linear regression is useful when one thing increases as another does. For example, as the size of a house gets bigger, its price usually goes up too. The algorithm finds the line that best describes this pattern, so we can predict prices from sizes.

Engagement Message

What are some other examples where two things increase together?

Section 3 - Instruction

A straight line is defined by its slope and intercept. The slope shows how much one value changes when the other increases by one. The intercept is where the line crosses the y-axis, or the starting value when x is zero.

Engagement Message

In your own words, what does the slope tell us?

Section 4 - Instruction

Let's work with real numbers! Say we have two houses:

Size (sq ft)Price ($)
1,000200,000
2,000300,000

The slope formula for a line between two points is: (y₂ - y₁) ÷ (x₂ - x₁)

Engagement Message

Can you calculate the slope using these two points?

Section 5 - Instruction

Using our houses: Slope = ($300,000 - $200,000) ÷ (2,000 - 1,000) = $100,000 ÷ 1,000 = $100 per sq ft.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal