harbor run -t LiteCoder/bikeshare-demand-forecastharbor download LiteCoder/bikeshare-demand-forecastBuild a Python pipeline that wrangles bike-share trip and weather data, engineers features, trains a Gradient-Boosting model to predict 2-hour rental counts, and produces a 48-hour forecast.
/app/bike_trips.csv — individual bike trips (columns: trip_id, start_time, end_time, start_station, end_station, duration_minutes, member_type). Timestamps are in YYYY-MM-DD HH:MM:SS format. Data spans 2023-06-01 to 2023-07-30./app/weather.csv — hourly weather observations (columns: timestamp, temperature_f, humidity, wind_speed_mph, precipitation_in, weather_condition). Same date range, one row per hour.Load & Clean: Read both CSVs into pandas DataFrames. Parse all timestamp/datetime columns as datetime64. Handle any missing values (drop or impute). Ensure numeric columns have correct dtypes.
Merge: For each 2-hour time window, associate the weather observation closest in time. The merged dataset must contain both trip-aggregated and weather columns.
Aggregate: Count the number of trips starting in each non-overlapping 2-hour window (bins aligned to even hours: 0:00–1:59, 2:00–3:59, …, 22:00–23:59). Each row represents one 2-hour window. Create a target column named rentals_next_2h that holds the rental count of the next 2-hour window (i.e., shifted forward by one bin).
Feature Engineering: Create at minimum these features:
hour — starting hour of the 2-hour window (0, 2, 4, …, 22)weekday — day of week (0=Monday … 6=Sunday)is_weekend — 1 if Saturday or Sunday, else 0rentals_2h_ago — rental count from the previous 2-hour window (lag-1)rentals_24h_ago — rental count from 24 hours ago (lag-12)temperature_f, humidity, wind_speed_mph, precipitation_inTrain/Validation Split: Split chronologically — first 80% of rows for training, last 20% for validation. Do NOT shuffle.
Model Training & Evaluation: Train a GradientBoostingRegressor (from scikit-learn) on the training set. Evaluate on the validation set and compute:
48-Hour Forecast: Using the latest available data, generate predictions for the next 24 consecutive 2-hour bins (48 hours total). Save the forecast to /app/forecast.csv.
All output files must be written to /app/.
/app/engineered_features.csv — The full feature matrix (train + validation) used for modeling. Must include at minimum the columns: hour, weekday, is_weekend, rentals_2h_ago, rentals_24h_ago, temperature_f, humidity, wind_speed_mph, precipitation_in, rentals_next_2h. Must contain a datetime or timestamp index/column identifying each 2-hour window.
/app/model.pkl — The trained GradientBoostingRegressor model, persisted via joblib or pickle.
/app/metrics.json — Validation metrics as a JSON object with exactly these keys:
{
"MAE": <float>,
"RMSE": <float>
}
Both values must be finite positive numbers.
/app/forecast.csv — 48-hour forecast with exactly 24 rows and at minimum these columns:
timestamp — the start of each predicted 2-hour window, in YYYY-MM-DD HH:MM:SS format, starting from the first 2-hour window after the last available data pointpredicted_rentals — the predicted rental count (numeric, non-negative)