# FAQ: Linear Regression - Points and Lines

This community-built FAQ covers the “Points and Lines” exercise from the lesson “Linear Regression”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

``````import codecademylib3_seaborn
import matplotlib.pyplot as plt
months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
revenue = [52, 74, 79, 95, 115, 110, 129, 126, 147, 146, 156, 184]
``````

In the exercise, what does the first line mean? In order to analyze my own dataset, how to import or apply them in this context?

Thanks,

I’m not getting passed the first and second exercise on this page. Need a shaming and the solutions please.

How causes changing the values of m and b affect the shape of the line?

As mentioned in the exercise,

The slope is a measure of how steep the line is, while the intercept is a measure of where the line hits the y-axis.

The equation of a line is

``````y = mx + b

// m: Slope
// b: y-intercept
``````

In the exercise, we have been provided initial values of `m = 8` and `b = 40` and have been asked in Step 3 to experiment with these value so that the line matches the revenue data. So, our initial equation of line is:

``````y = 8x + 40
``````

Look at three situations:

• Situation 1: Keep `m` (slope) fixed, but change `b` (y-intercept)

If you don’t change slope, then the steepness of the line remains unchanged. Changing the y-intercept just moves the line up and down while preserving the steepness. For example,
`y = 8x + 60` will shift the line up so that it intercepts the y-axis at a value of `60`, but steepness remains unchanged.
`y = 8x + 10` will shift the line down so that it intercepts the y-axis at a value of `10`, but steepness remains unchanged.
`y = 8x - 30` will shift the line down so that it intercepts the y-axis at a value of `-30`, but steepness remains unchanged.
`y = 8x + 0` will shift the line so that it intercepts the y-axis at a value of `0` i.e. it passes through the origin of the axes, but steepness remains unchanged.

• Situation 2: Change `m` (slope), but keep `b` (y-intercept) fixed

If y-intercept is fixed, then we aren’t moving the line up and down. Instead, changing the slope means the steepness of the line is changed. For example,
`y = 25x + 40` will intersect the y-axis at a value of `40`, but it will rise sharply as we go from left to right along the x-axis (steeper line).
`y = 2x + 40` will intersect the y-axis at a value of `40`, but it will rise less sharply as we go from left to right along the x-axis (less steeper line).
`y = -3x + 40` will intersect the y-axis at a value of `40`, but it will slant downwards as we go from left to right along the x-axis.
`y = 0x + 40` will intersect the y-axis at a value of `40`, and since slope/steepness is `0`, so it will be a horizontal line.

• Situation 3: Change `m` (slope), and change `b` (y-intercept)
This will change both the steepness of the line and the point where y-axis is intersected. Both the shape (steepness) of the line as well as the y-intercept (moving line up and down) are being changed. For Example,
`y = 3x + 15` will intersect the y-axis at a value of `15` and the slope of the line will be `3`

In the exercise, you are expected to experiment with values of `m` and `b` (i.e. by changing the steepness of the line and moving it up and down) so that the line matches the revenue data.

A visual experiment will be much more instructive than what I wrote. So, I suggest you do the following:

• Go to an online graphing calculator (https://www.desmos.com/calculator)

• Enter an equation such as `y = 2x + 11` . A line will appear. You can zoom in and out to get a clearer picture.

• Now experiment with different values of `m` and `b`. What happens if you type in `y = 2x + 30` or `y = 2x - 5` or `y = 4x + 11` or `y = 16x + 11` or `...` ? See how different values of `m` change the steepness of the line, but doesn’t change the y-intercept. Observe how changing `b` moves the line up and down, but doesn’t affect steepness. When both `m` and `b` are changed, then both changes happen together.

thanks you very much