Day 14 In-Class Assignment: Evaluating Models

Contents

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#

\[y = Ax + B\]

Quadratic Model#

\[y = Ax^2 + Bx + C\]

Exponential Model#

\[y = A\exp(-Bx) + C\]
#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.

✅  2.6 Show and tell an audience: In this task you will prepare a mini presentation to share your answers to part 2.1 with the class. Save the figure(s) that support your answers for part 2.1, and include it in a 1-slide presentation that you will present to your teammates and other class groups. Your slide must follow best practices for presentation such as:#

  • The models must be clearly presented (for example, in legends, figure title, or as figure captions)

  • The selected figures must enhance understanding, i.e., do not use media that does not support the purpose or improves understanding. Everything on the slide must have a purpose.

  • The fonts and lines must be legible from any where in the classroom. You might need to experiment with different font sizes and line widths to find something that works well.

  • Consider adding the formatting that gives clear figures in the slides in your code portfolio for easy future access.

✅  2.7 Show and tell a readership: in this task you will prepare a mini report to share your answers to the questions above. Save the figure that supports your answers for part 2.1, and include it in a 1-page report. Your report must follow best practices for including figures, such as:#

  • The models must be clearly presented (for example, in legends, figure title, or as figure captions)

  • The selected figures must enhance understanding, i.e., do not use media that does not support the purpose or improves understanding.

  • The fonts and lines must be legible. Typically, it is good practice to make sure the fonts in the figure are of the same size as those in the rest of the document. You might need to experiment with different font sizes and line widths to find something that works well.

  • Make sure the figures are of sufficient resolution, which for is 300 DPI (dots per inch). See the dpi argument in the savefig function.

  • Consider adding the formatting that gives clear figures in reports in your code portfolio for easy future access.

✅  2.8 What did you observe when preparing your slide and report? Do the figures needed for 2.6 and 2.7 require different formatting? Did something about preparing these figures surprise you?#

NOTE: Please make sure your share your group’s presentation and report with your instructors!

Put your answer here.


To wrap up, check in with your instructor and report your findings from Part 2.8!#


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 2025, Department of Computational Mathematics, Science and Engineering at Michigan State University.