Day 14 In-Class Assignment: Evaluating Models#
✅ Put your name here.
#✅ Put your group member names here.
#In this assignment we’re going to look at how we might evaluate the models we fit to data.
The learning goals of the assignment are to:
Describe the utility of fitting trendlines to data, in the context of making predictions about the future
Use best-fit lines to make predictions
Quantitatively and qualitatively describe how to determine the goodness of fit for a given line
Assignment instructions#
Work with your group to complete this assignment. Instructions for submitting this assignment are at the end of the notebook. The assignment is due at the end of class.
1. Coming to a Consensus on Goodness of Fit#
✅ In the pre-class assignment, you were tasked with coming up with an algorithm for determining the goodness of fit (Part 2.2). Discuss with your group the different algorithms that you each came up with. What are the differences between each of your algorithms? What are the benefits of each algorithm? What are the drawbacks?
As a group, reach a consensus on a good algorithm for determining the goodness of fit. Write your group’s algorithm in the cell below. When thinking about how to design your algorithm it can be useful to explore the concept of a “residual” when fitting a line to data. Basically, a residual is a measurement of how far a data point is from the expected value generated by our line (or curve) of best fit. You can see a visual representation of this here: https://www.khanacademy.org/math/statistics-probability/describing-relationships-quantitative-data/regression-library/a/introduction-to-residuals
✎ Put your answer here.
🛑 STOP! Check in with an instructor before you move on!#
2. Modeling the Air Atop Everest#
The higher you are above sea level, the thinner the air gets. For instance, in Denver (elevation: 1 mile, or 1600 meters), air density is about 12% lower than it is in East Lansing. For every eight breaths you take in Michigan, you’ll need nine breaths in Denver to get the equivalent amount of air.
This difference in air density with altitude can be lethal for mountain climbers, where the density of air can be a third or less the value at sea level. Meaning that for every one breath you take in Michigan, you’d need to take three breaths on top of Mount Everest to get the equivalent amount of air.
You are working for a company that specializes in selling air tanks to climbers. You’ve been tasked with writing a piece of code that can determine the density of air for a given altitude so that your company can calculate how many air tanks a climber will need.
You don’t have much of a physics or chemistry background, so you’re not sure how to make a physical model for this situation. But you do have data from a previous expedition, where the climbers took measurements of the density at different heights.
✅ 2.1 Use the data provided to test out different models. Decide on one model that you feel best fits the data.#
The three models you should test out are:
Linear Model#
Quadratic Model#
Exponential Model#
#Data to use for your model
#Height is in kilometers, density is in kg/m^3
import numpy as np
height = np.array([0.0,0.17,0.34,0.52,0.69,0.86,1.03,1.21,1.38,1.55,1.72,1.9,2.07,2.24,2.41,2.59,2.76,2.93,3.1,3.28,3.45,3.62,3.79,3.97,4.14,4.31,4.48,4.66,4.83,5.0])
density = np.array([1.2,1.23,1.19,1.2,1.17,1.12,1.07,1.05,1.06,1.04,1.03,1.01,0.95,0.97,0.96,0.93,0.93,0.88,0.87,0.9,0.83,0.84,0.84,0.8,0.79,0.8,0.78,0.77,0.73,0.76])
# Write your code here
✅ 2.2 Code up the algorithm you defined in part 1 and quantitatively compare how well each model fits the data.#
# Write your code for calculating goodness of fit here
✅ 2.3 Which model best fits the data? Is it substantially better than the other models?#
Write your answer here
✅ 2.4 Mount Everest is 8.85 kilometers high. What does each model predict for the density of air on top of Mount Everest?#
✎ Put your answer here.
✅ 2.5 What do you believe the density of of air is at the top of Mount Everest? Justify your answer using the results from the previous questions.#
✎ Put your answer here.
To wrap up, check in with your instructor#
Before calling your instructor over, as a group come up with an explanation for what model your group has chosen and why you’ve chosen it. You should to be able to justify your reasoning using a calculation or a figure of some sort.
Once your whole group is ready, call over an instructor and present your results to them.
Assignment wrapup#
Please fill out the form that appears when you run the code below. You must completely fill this out in order to receive credit for the assignment!
from IPython.display import HTML
HTML(
"""
<iframe
src="https://cmse.msu.edu/cmse201-ic-survey"
width="800px"
height="600px"
frameborder="0"
marginheight="0"
marginwidth="0">
Loading...
</iframe>
"""
)
© Copyright 2023, Department of Computational Mathematics, Science and Engineering at Michigan State University.