← 返回 twosigma 的题目列表QR OA — NYC Temperature Regression
类型:qbank
Analyze daily town temperatures and use simple linear models to predict NYC temperature. The task mixes pandas-style aggregation, statistics, least-squares regression, MSE comparison, and greedy feature selection.
Requirements
Given historical daily temperatures for NYC and multiple towns, implement functions that answer a fixed set of questions:
Find the location with the largest daily temperature variation, measured by standard deviation.
When Town2's daily temperature is between 90 and 100 inclusive, compute the median NYC daily temperature and round it to the nearest integer.
For each individual town, fit a simple linear model with intercept to predict NYC temperature; return the rounded sum of absolute slope coefficients, excluding intercept terms.
Find the single town that best predicts NYC temperature, where best means lowest in-sample MSE from the fitted linear model.
Find the pair of towns that jointly best predicts NYC temperature by the same MSE criterion.
Return a set of five towns that jointly predict NYC temperature as well as possible. Candidates describe this as a feature-selection / Lasso-like extension.
Notes
This is the second stable QR OA task and often appears together with Linear Interpolator and Efficient OLS Regression.
The task rewards exact data manipulation and formula hygiene: standard deviation definition, median filtering, intercept handling, coefficient extraction, MSE comparison, and rounding all matter.
For the five-town version, be ready to explain a greedy feature-selection approach if exhaustive search is too expensive for the dataset size.
Preparation
Reimplement simple linear regression with an intercept using both closed-form equations and a small matrix solve.
Practice pandas group/filter/aggregate operations for conditional medians and standard deviations.
Write a feature-selection helper that evaluates candidate singletons, pairs, and greedy additions by MSE.