KatInterview

Forecasting Hourly Dock Demand for a Bike-Share Station

Machine LearningModel answer
MediumModel answerMachine Learningtime-seriesforecastingfeature-engineering

Last updated

Design an ML pipeline that forecasts 24 hours of bike demand per station, covering target framing, leakage-safe features, validation, and model choice.

Context

A bike-share operator wants a forecast of how many bikes each station will need over the next 24 hours. Operations staff use it to decide when and where to truck bikes between stations. The forecast must be produced per station and per hour.

You have three data sources:

  • Station logs (hourly_logs): timestamp, station ID, bikes currently available, and docks currently free, covering roughly the past two years.
  • Weather history: hourly temperature, precipitation, and wind speed.
  • Calendar data: flags for weekends, public holidays, and local events such as concerts and sports games.

What you should answer

  1. Target definition. The logs record inventory, not rentals. Explain how you would turn them into a supervised learning target. The ops team needs a bike count, so say how that connects to your target.
  2. Features. Propose five features that capture seasonality, trend, and external influences on usage. For each, say what could leak future information.
  3. Validation. Describe how you would cross-validate on this time series without leaking information from the future.
  4. Models. Pick a baseline and a more complex model, and justify both.

Constraints

  • Predictions must be granular: one per station, per hour.
  • Training samples must not contain look-ahead information.
  • The system must stay reasonable when usage suddenly spikes or drops, for example during a storm or while a station is under maintenance.

Hints

Hint 1

Start by asking what the logs actually measure. Inventory at one moment is different from rentals during an hour, and the difference between consecutive snapshots is a useful place to start.

Hint 2

For any feature, ask whether its value would be known at the moment you make the forecast. Lags that are shorter than the forecast horizon are a common trap.

Hint 3

A random shuffle of rows is the wrong way to split time series data. Think about an expanding window with a gap between train and test.