While you wait: Request for participation π±π»
Weβre working on a manuscript about experimenting with AI tools to support student learning, and weβd love to incorporate your feedback on your experience using Codex for homework feedback or other aspects of the course. We would be so appreciative if you would fill out the following anonymous survey:
[LINK REMOVED AFTER CLASS]
It should take no more than 5 minutes to complete.
[QR CODE REMOVED AFTER CLASS]
If you have any questions about the form or the project, weβre always happy to chat!
Prof. Γetinkaya-Rundel and Marie Neubrander (PhD student in Statistical Science)
ImportantOptional
Participation is completely optional, but your feedback is greatly appreciated.
Announcements
If you havenβt yet filled out your team evaluation on TEAMMATES, please do so immediately after class.
From last time
Go to your ae project in Positron.
If you havenβt yet done so, make sure all of your changes up to this point are committed and pushed, i.e., thereβs nothing left in your source control pane.
If you havenβt yet done so, pull to get todayβs application exercise file: ae-12-chicago-taxi-classification.qmd.
Work through the application exercise in class, and render, commit, and push your edits by the end of class.
Exam 2 review
Exam 2
Exam 2 is on Wednesday, starts promptly at 1:25 pm!
Covers all material up to and including todayβs lecture
Sample exam + model solutions for select HW questions are posted
Exam will be in class, closed book, no calculators, no computers, just 1 notes sheet
Notes sheet: 8.5x11, both sides, hand written or typed, any content you want, must be prepared by you
Weβll direct you to your seat so get here early to allow time to get settled and read the instructions
Types of questions
Multiple-choice:
Some will be single best answer, no partial credit
Some will be at least one correct answer, with partial credit, and clearly identified with βSelect all that applyβ
Open-ended:
Short answer, show your work, justify your reasoning
Could we go over an example of how to write the different regression models? Iβm trying to understand how to use the model output to write the fitted equation and interpret the slope, intercept, and all the different coefficients that have different tiers/dummy variables. Iβm also confused about what changes between multiple regression, categorical predictors, interaction models, and logistic regression. How are you suppose to show the different levels?
Model output: Linear
Each row of the output of the tidy() function supplies a coefficient
cars_lin_fit<-linear_reg()|>fit(mpg~wt, data =mtcars)tidy(cars_lin_fit)
Exponentiating undoes the natural log. It converts log odds to odds.
To get a probability, divide the odds by 1 + odds.
Exponentiate the whole fitted expression to predict odds; exponentiate a slope to get an odds multiplier for a one-unit increase in the corresponding predictor.
Student question(s):
Would love clearer explanations on the difference between log odds, exponentiation, and what numbers or conversions we need to do in order to interpret intercepts and slopes for logistic regression. A clearer template on what are interpretations should be like would be extremely helpful!
explanations for logistic regression + interaction models
Source: Lectures 19β20; practice exam Q19 intercept.
Logistic regression: Interpretations
Sample interpretations for a model with main effects of predictors:
Coefficient
Interpretation, holding other predictors constant
Intercept \(b_0\)
At numerical predictors = 0 and categorical predictors at their reference levels, predicted log odds of the event are \(b_0\).
Numerical slope \(b_j\)
For each additional one unit of \(x_j\), predicted log odds change by \(b_j\); predicted odds are multiplied by \(e^{b_j}\).
Category coefficient \(b_j\)
For this level compared with the reference level, predicted log odds differ by \(b_j\); predicted odds are multiplied by \(e^{b_j}\).
. . .
A multiplier of 0.8 means 20% lower odds; 1.2 means 20% higher odds. These are changes in odds, not percentage-point changes in probability.
Source: Lectures 19β20; practice exam Q19 suggested answer.
Q19: Interpreting the spam model
Let \(\hat p=P(\text{spam}=1)\), \(d\) be the number of dollar signs, \(W=1\) if βwinnerβ appears, and \(U=1\) if βurgentβ is in the subject (0 otherwise).
Intercept: For emails with 0 dollar signs, no βwinnerβ, and no βurgentβ in the subject, predicted log odds of spam are β2.24, on average. The predicted odds are \(e^{-2.24}\).
Dollar: All else held constant, for each additional dollar sign, predicted odds of spam are multiplied by \(e^{-0.0597}\approx0.942\) (5.8% lower).
Winner: All else held constant, the predicted odds of emails with βwinnerβ being spam are \(e^{1.63}\approx5.10\) times those without it, on average.
Urgent: All else held constant, the predicted odds of emails with βurgentβ in the subject being spam are \(e^{2.99}\approx19.9\) times those without it, on average.
Source: Practice exam Q19 and suggested answer (rounded coefficients).
Sensitivity asks: Of all actual positives, how many did we catch?
If there are 100 actual positives and we detect 90, sensitivity is 90%: we miss 10.
If we detect 99, sensitivity is 99%: we miss 1.
When missing a positive has a high cost, higher sensitivity helps reduce that costly error.
. . .
Threshold tradeoff: Lowering the probability cutoff for a positive prediction generally catches more positives, but can also create more false positives. Choose a threshold with the error costs in mind.
Source: Lecture 21, βSensitivityβ, βFalse negative and positiveβ, and ROC curves.
Model selection: How much improvement is enough?
Use a criterion that balances fit and complexity, and state your reasoning.
On the same observations, adding predictors cannot lower ordinary \(R^2\); this alone does not justify a larger model.
Adjusted \(R^2\) penalizes additional predictor coefficients. If the instruction is to maximize it, select the model with the higher value.
There is no universal cutoff for βsmall enoughβ. For a judgment-based choice, weigh the size of the improvement against complexity, interpretability, and the modeling goal.
Example: Q17b β Adjusted \(R^2\) goes from 0.187 (runtime) to 0.191 (runtime + rating).
The higher-adjusted-\(R^2\) rule selects runtime + rating. The gain is only 0.004, so preferring the simpler model for parsimony is also defensible with an explanation.
Source: Lecture 18, adjusted R-squared and balancing fit and complexity; practice exam Q17b suggested answer; AE 10 model comparison.
Web scraping: The workflow
Inspect the page. Use SelectorGadget to click a desired element, exclude unwanted matches, and check that the highlighted set matches what you want.
Read the page with read_html(url).
Select the relevant nodes with html_elements("CSS selector").
Extract text with html_text() / html_text2(), or an attribute with html_attr("href").
Combine and clean the results in a tibble; make relative links into full URLs before reading article pages.
Repeat a one-page function over article URLs with map_chr(); save the scraped data for analysis.
. . .
A selector identifies nodes; the extraction function determines what you take from them. Scrape in a script and save results to avoid scraping again on every render.
Source: Lectures 11 and 13; AE 7β8 Chronicle scraping scripts; practice exam Q24β25.
Q24: Text or an attribute?
<div class="article-listing"><a class="title" href="/article/2026/09/duke-opinion-on-dining">On dining at Duke</a><span class="byline">By Jane Doe</span></div>