Regression Activity - Pt. 2: Regression Modeling

Regression Modeling



There are a few ways to create a line of best fit, but we will use Python to run a linear regression for us! It will generate our line of best fit.

🎯 Checkpoint 5. a: Storing your team’s data in lists!

Replace the ?? placeholder with the color values and nitrate concentrations from the RBG activity and scatterplot!

IMPORTANT: The color values and nitrate concentrations must be in the exact same order.

Click the ▶️ Run Code button to run the block and store your data.

Storing Your Data

Recreating Your Team’s Scatterplot

🎯 Checkpoint 5. b: Scatterplots in Python!

Replace the ?? placeholders with the x variable (color_data) in the first blank and the y variable (nitrate_ppm) in the second.

Click the ▶️ Run Code button to create a scatterplot that should match your group’s paper plot.

Running the Linear Regression

🎯 Checkpoint 5. c: Running a regression in Python

Replace the ?? placeholders with the x variable (color_data) in the first blank and the y variable (nitrate_ppm) in the second blank.

Click the ▶️ Run Code button to run the block and generate the equation for the line of best fit.

NOTE: The linear regression produces the equation for the line of best fit. After we know the equation, we can graph it.

Remember y = mx + b?
We can just substitute!

🎯 Checkpoint 5. d: Printing the Regression Equation

No code edits needed!

Click the ▶️ Run Code button to see the slope-intercept equation of your regression line.

Plotting the Regression Line

🎯 Checkpoint 5. e: Plotting regression line in Python

No code edits needed!

Click the ▶️ Run Code button to plot the scatterplot with the regression line included.

Activity - Draw your line of best fit on your group’s scatterplot

🎯 Checkpoint 5. f: Plotting regression line on paper

Materials Needed:
- Poster Markers
- Scatterplot
- Yardstick

Using the exact positioning the line of best fit python generated, copy that line onto your group’s scatterplot. When finished, bring your group’s plot to the front of the class.