CoolFace
Modelpublic

fairleap-ai/fairleap-v1-earnings-xgboost-11k

sourceHugging Facemitupdated 1mo agoView on Hugging Face
1likes
Model Card

<p align="center"> <img src="assets/logo.png"/> <h1 align="center">fairleap-v1-earnings-xgboost-11k</h1> </p>

An XGBoost regressor that forecasts a Gojek/GOTO driver's daily earnings in IDR from their own recent earnings history, calendar context, and a self-reported wellness score.

It is the earnings half of the Fairleap forecasting pair. Its output is also the first input feature of `fairleap-v1-laborsupply-xgboost-2k`, which forecasts hours worked.

๐Ÿ“Š Model Details

Architecturexgboost.sklearn.XGBRegressor, booster=gbtree
Objectivereg:squarederror
Boosting rounds750
Max depth3
Learning rate0.3
Random state42
Input features20 (ordered โ€” see below)
Output1 continuous value: predicted daily earnings, IDR
Total tree nodes10,598 (4,924 splits + 5,674 leaves) โ€” the "11k" in the name
Mean nodes per tree14.1 of a possible 15
Artifactapp/earnings_model.pkl, 840 KB, joblib
Versionv1
LicenseMIT

๐ŸŽฏ Intended Use

Giving an individual driver a short-horizon (roughly one to fourteen day) indication of expected daily income, so that budgeting and savings advice downstream has a number to work from. The model is trained per-driver-history: it reads only that driver's own past daily totals.

Out-of-Scope Use

  • โ€”Any real financial decision. The model is trained entirely on synthetic data (see below) and its Rยฒ of 0.397 means it explains under 40% of the variance even on that synthetic test split.
  • โ€”Determining pay, eligibility, credit, or employment. Do not use these forecasts as an input to anything that decides what a person receives or is entitled to.
  • โ€”Fleet-level or market-level forecasting. There is no cross-driver, geographic, or seasonal signal in the feature set beyond day-of-week.
  • โ€”Horizons beyond ~14 days. Lag features degrade to constants past the supplied history window.

๐Ÿ”ข Feature Schema

Feature order is load-bearing. This is a plain XGBRegressor with no column-name validation at predict time โ€” passing the right columns in the wrong order produces plausible numbers, not an error.

#FeatureTypeDescription
0day_of_weekint 0โ€“6Monday = 0
1is_weekendint 0/11 when day_of_week >= 5
2wellness_scoreintSelf-reported wellness, constant across the forecast window
3rolling_mean_7floatMean of the last 7 historical daily earnings
4rolling_std_7floatPopulation std of the last 7 historical daily earnings
5rolling_mean_14floatMean of the last 14 historical daily earnings
6โ€“19lag_1 โ€ฆ lag_14floatDaily earnings 1โ€“14 days before the target day

Rolling statistics are computed once from the tail of the supplied history and are therefore constant across every day in a forecast window โ€” they are not updated recursively as the forecast walks forward. Lags fall back to NaN when they reach before the start of the supplied history; XGBoost handles NaN natively via its default split direction.

๐Ÿš€ How to Use

Directly

python
import joblib
import pandas as pd

model = joblib.load("app/earnings_model.pkl")

FEATURES = ["day_of_week", "is_weekend", "wellness_score",
            "rolling_mean_7", "rolling_std_7", "rolling_mean_14"] + \
           [f"lag_{i}" for i in range(1, 15)]

X = pd.DataFrame([{...}], columns=FEATURES)   # order matters
earnings = abs(model.predict(X)[0])

As a service

sh
pip install -r requirements.txt
python wsgi.py                                    # dev, port 5000
gunicorn --bind 0.0.0.0:5000 wsgi:app             # production
docker compose up                                 # container

GET / returns a healthcheck and the route table.

POST /predict/earnings โ€” feature construction from raw daily logs is handled for you by app/regressor_utils.py:

jsonc
{
  "start": "2025-05-13",
  "end": "2025-05-20",
  "wellness_score": 20,
  "daily_logs": [
    { "day": "2025-03-25", "total_earnings": 155000, "total_distance": 100.0,
      "total_fare": 150000, "total_tip": 5000, "total_trips": 8 }
  ]
}

Supply at least 14 days of daily_logs for the lag features to be populated, and 14 for rolling_mean_14. Response:

jsonc
{
  "status": "success",
  "currency": "IDR",
  "predictions": [
    { "date": "2025-05-13", "earnings": 171613.640625 }
  ]
}

Predictions are passed through abs(), so the service never returns negative earnings โ€” note this masks rather than fixes a negative prediction.

Configuration

VariableDefaultPurpose
MODEL_PATH./app/earnings_model.pklPath to the joblib artifact
PORT5000Listen port

The model is loaded at import time; a failure raises RuntimeError and the process will not start.

๐Ÿ“š Training Data

**fairleap-ai/fairleap-driver-earnings-regression-500** โ€” 500 rows, MIT.

Fully synthetic ride-event records generated by data_gen.py, one row per completed ride:

ColumnDescription
driver_idSynthetic driver identifier
timestampRide timestamp, unique and strictly increasing per driver
day_of_week0โ€“6, Monday = 0
hour_of_day0โ€“23
location_clusterIndonesian city label
hours_workedHours attributed to the ride
rides_completedRides in the record
earningsEarnings in IDR โ€” the target
wellness_scoreSelf-reported driver wellness
preferred_locationDriver's stated preferred city
avg_ride_duration_minutesMean ride duration

๐Ÿ”ฌ Training Procedure

Lags 1โ€“14 and 7/14-day rolling statistics are derived from the earnings column, rows with resulting NaNs are dropped, and the frame is split 80/20 with train_test_split.

python
XGBRegressor(n_estimators=750, learning_rate=0.3, max_depth=3, random_state=42)

๐Ÿ“ˆ Evaluation

Held-out 20% split of the dataset above.

MetricValue
MAE52,875.75 IDR
Rยฒ0.3968

โš ๏ธ Limitations & Bias

  • โ€”Synthetic data only. No claim this model makes about driver income reflects real Gojek/GOTO earnings. It was never validated against real driver data.
  • โ€”Weak absolute accuracy. Rยฒ = 0.397 on synthetic test data. A mean absolute error of ~52,900 IDR is large relative to the daily earnings being predicted.
  • โ€”Train/serve skew. Lags and rolling windows are built at training time over per-ride event rows โ€” the dataset carries hour_of_day and multiple rows per driver per day. At serving time regressor_utils.py builds one row per day with lags over daily totals. lag_1 means "the previous ride" during training and "yesterday" during inference. This is a known defect, not a design choice.
  • โ€”Static rolling features. Rolling statistics do not advance across the forecast window, so every day in a multi-day forecast sees the same rolling_mean_7 / rolling_std_7 / rolling_mean_14.
  • โ€”`wellness_score` is self-reported and held constant across the window, so any bias in how drivers rate themselves is carried straight into the forecast.
  • โ€”No geographic or seasonal signal. location_cluster and preferred_location are in the dataset but not in the feature set. Holidays, weather, promotions and surge are absent entirely.
  • โ€”No uncertainty estimate. A single point prediction is returned with no interval, which overstates confidence for a model at this accuracy.

๐Ÿ› ๏ธ Tech Stacks

  • โ€”xgboost: An optimized gradient boosting library designed to be highly efficient, flexible, and portable for supervised learning problems.
  • โ€”scikit-learn: A robust machine learning library that provides simple and efficient tools for data mining and data analysis.
  • โ€”pandas: A powerful data manipulation and analysis library offering labeled data structures and operations for manipulating numerical tables and time series.
  • โ€”numpy: A foundational library for numerical computing in Python, supporting large, multi-dimensional arrays and matrices.
  • โ€”joblib: A library for lightweight pipelining and efficient serialization of Python objects, often used for persisting machine learning models.
  • โ€”flask: A lightweight and flexible WSGI web application framework designed to get applications up and running quickly.
  • โ€”gunicorn: A Python WSGI HTTP server for UNIX that's commonly used to serve Flask or Django web applications in production.

โš™๏ธ Installation

sh
git clone https://github.com/Fairleap-AI/fairleap-v1-earnings-xgboost-11k
cd fairleap-v1-earnings-xgboost-11k
docker compose up

๐Ÿ“ License

This project is licensed under the MIT License.