How would you forecast bike demand?
Two SigmaData Scientist · Technical ScreenLast updated
This problem tests your ability to design a robust machine learning pipeline for time-series demand forecasting, focusing on feature engineering for exogenous variables and evaluation metrics for spatial-temporal data.
Scenario
You are tasked with building a machine learning system to predict the hourly demand for bikes at specific docking stations in a major metropolitan area. The goal is to optimize bike redistribution to prevent station vacancies and overflows.
Data Available
- Historical bike trip logs:
start_station_id,end_station_id,start_time,end_time. - Station metadata:
station_id,capacity,latitude,longitude. - External features: Hourly weather data (temperature, precipitation, wind speed), local holiday calendars, and public transit strike/maintenance schedules.
Your Task
- Propose a data processing pipeline: How would you structure the raw trip data for a supervised learning model?
- Feature Engineering: Describe the features you would create to capture cyclic patterns (daily/weekly) and exogenous influences.
- Model Selection: Compare two different modeling approaches (e.g., statistical vs. deep learning) for this problem, highlighting the trade-offs between interpretability and accuracy.
- Evaluation: Propose a validation strategy that respects the temporal nature of the data. Which metric would you use to evaluate performance, and how do you handle stations with very low, intermittent demand?
Hints
Hint 1
Consider that demand at time T is heavily dependent on the state of the station at time T-1, which suggests a recursive or sequence-based modeling approach.
Hint 2
For the validation strategy, avoid standard K-fold cross-validation; think about how a 'walk-forward' or 'sliding window' approach prevents data leakage.
Hint 3
Think about how you would account for the 'spatial' correlation—i.e., if a user cannot find a bike at station A, they might walk to station B.
Follow-up questions
- How would you handle cold-start problems for a newly installed docking station with no historical data?
- If the business priority shifts from 'minimize total error' to 'minimize the number of completely empty stations,' how would you adjust your model's loss function?
- How would your approach change if you had to move from hourly predictions to real-time, minute-by-minute updates?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.