Download (right-click, save target as ...) this page as a jupyterlab notebook Lab29
LAST NAME, FIRST NAME
R00000000
ENGR 1330 Exercise 30 - Homework
The following data are the temperature as a function of vertical depth in a chemically active settling pond.
Depth (cm) | Temp ($^o$C) |
---|---|
0.1 | 21.2 |
0.8 | 27.3 |
3.6 | 31.8 |
12 | 35.6 |
120 | 42.3 |
390 | 45.9 |
710 | 47.7 |
1200 | 49.2 |
1800 | 50.5 |
2400 | 51.4 |
Fit the following data models.
Produce a plot of the data and data model for each model (4 plots)
Select the "best" model based on the $R^2$ value.
Use the best model to predict the temperature at 1 meter and 2 meters depth.
# Load the necessary packages
import numpy as np
import pandas as pd
import statistics
import math
from matplotlib import pyplot as plt
import statsmodels.formula.api as smf
# build the data lists
# build a dataframe
# Initialise and fit a linear regression model using `statsmodels`
# Predict values
# Plot regression against actual data
# build the data lists
# build a dataframe
# Initialise and fit an exponential regression model using `statsmodels`
# Predict values
# Plot regression against actual data
# build the data lists
# build a dataframe
# Initialise and fit a logarithmic regression model using `statsmodels`
# Predict values
# Plot regression against actual data
# build the data lists
# build a dataframe
# Initialise and fit a power-law regression model using `statsmodels`
# Predict values
# Plot regression against actual data
# Choose the "good" data model
# With your "good" model answer the questions