Singapore-based practical guides, tutorials and experiments in AI, computing, modelling, simulation, optimisation and quantum computing, with research notes and hands-on workflows.
Pocket Data Science III: Exploring Regression Baselines and Ensembles on Android with Antigravity CLI
A hands-on walkthrough exploring regression baselines, metric alignment in log space, Ridge regression, and CatBoost on the Kaggle House Prices dataset using Android Termux.
A hands-on walkthrough exploring regression baselines, metric alignment in log space, Ridge regression, and CatBoost on Kaggle’s House Prices dataset using an Android phone running Termux and Google Antigravity CLI.
In previous installments of this series (Titanic and Spaceship Titanic), we explored binary classification on mobile hardware using Google Antigravity CLI (agy) running inside an Android Linux environment.
In this follow-up, we turn to tabular regression with another classic entry-level benchmark: Kaggle’s House Prices: Advanced Regression Techniques (based on Dean De Cock’s Ames, Iowa housing dataset). Regression introduces continuous error distributions, high-dimensional collinearity, and non-linear evaluation metrics that reward a disciplined, step-by-step baseline process.
1 · The Mobile ML Stack
Every command, data transformation, cross-validation run, and Kaggle submission was executed locally on smartphone hardware:
Host Platform: Android 14 running Termux with a Debian userspace via PRoot Distro on 64-bit ARM (aarch64).
Agentic CLI:Google Antigravity CLI (agy) operating as an interactive coding assistant to execute background scripts and inspect test metrics.
Toolchain: Python 3.14 with pandas, numpy, scikit-learn, catboost, and the official kaggle CLI.
Resource Profile: Execution remained lightweight (under 2GB RAM peak) with 5-fold cross-validation completing within seconds to a couple of minutes per model.
2 · Experiment Progression: From Random to Blended Ensemble
We tracked eight progressive submissions on the public Kaggle leaderboard (evaluated against 3,734 active teams):
Exp
Model & Strategy
Complexity
Kaggle RMSLE
LB Rank
Percentile
Teams Beaten
Exp 01
Empirical Random Prior
Sample w/ replacement from train
0.56940
#3,586
Bottom 4%
148
Exp 03
Arithmetic Mean
Single scalar ($180,921.20)
0.42577
#3,535
Bottom 5%
199
Exp 02
Median Baseline
Single scalar ($163,000.00)
0.41657
#3,528
Bottom 5%
206
Exp 04
Geometric Mean
Optimal log scalar ($166,716.73)
0.41637
#3,527
Bottom 5%
207
Exp 05a
1D Piecewise Constant
10 values: log-mean by OverallQual
0.22613
#3,355
Top 90%
379
Exp 05b
2D Piecewise Constant
~170 values: Neigh × OverallQual
0.20945
#3,320
Top 89%
414
Exp 06
Ridge Regression
5-Fold CV + OHE + Scaler
0.13002
#1,438
Top 38.5%
2,296
Exp 07
CatBoost Regressor
5-Fold CV + 44 Native Categoricals
0.12601
#992
Top 26.6%
2,742
Exp 08
Blended Ensemble
80% CatBoost + 20% Ridge (log blend)
0.12363
#704
Top 18.8%
3,030
3 · The Mathematics of Error: Mean vs. Median vs. Geometric Mean
Kaggle evaluates submissions using Root Mean Squared Logarithmic Error (RMSLE):
RMSLE = √ [ (1/N) Σ (ln(1 + ŷ) – ln(1 + y))² ]
Because errors are squared in log space, evaluating different constants highlights key statistical properties:
Arithmetic Mean ($180,921.20 — Score: 0.42577): Minimizes squared error in raw dollars (Σ (y – C)²). However, Ames home prices are right-skewed by luxury houses (up to $755k). Overpredicting typical modest homes incurs a heavy relative penalty in log space.
Median ($163,000.00 — Score: 0.41657): Minimizes Mean Absolute Error (MAE). Being resistant to high-end outliers, it lands closer to the typical home, outperforming the arithmetic mean by 0.0092 RMSLE.
Geometric Mean ($166,716.73 — Score: 0.41637): Under RMSLE, the mathematically optimal single scalar is the mean of the logarithms: C* = exp(E[ln(1 + y)]) – 1. This achieved the best possible score for a single global number.
4 · The Bridge: Piecewise Constant Lookup Tables
In statistical learning, regression decision trees are fundamentally algorithms that partition feature space into piecewise constant regions. We tested this manually by creating simple group lookup tables:
Overall Quality (1D Piecewise): Grouping into 10 quality tiers (1 to 10) and predicting each tier’s log-mean dropped the error from 0.416 to 0.22613. Quality 1 averages ~$49k, scaling smoothly to Quality 10 at ~$409k.
Neighborhood × Overall Quality (2D Piecewise): Combining geographic location with quality produced an RMSLE of 0.20945, demonstrating how much predictive signal exists in basic category stratification before training any models.
5 · Machine Learning Baselines & Ensembling
We then trained two standard models on log-transformed targets across 5 folds:
Ridge Regression (Exp 06 — Score: 0.13002): Standardized numerical features with one-hot encoded categoricals and L2 penalty (α ≈ 20) to handle multicollinearity among square-footage variables.
CatBoost Regressor (Exp 07 — Score: 0.12601): Utilized native ordered target encoding across 44 categorical columns with symmetric trees, capturing non-linear feature interactions without manual one-hot expansion.
Blended Ensemble (Exp 08 — Score: 0.12363): Combining both models with an 80% CatBoost / 20% Ridge geometric blend in log space dropped error to 0.12363, reaching Rank #704 (Top 18.8%).
Key Engineering Takeaways:
Establish a Baseline Hierarchy First: Measuring random sampling, global constants, and simple lookup tables provides clear benchmarks to verify whether trained models add genuine predictive value.
Match the Optimization Loss to the Evaluation Metric: In competitions evaluated on log metrics, training on log-transformed targets and ensembling in log space is mathematically necessary to avoid skew distortion.
Contextualize Benchmark Ranks: Introductory datasets feature many incomplete or sample submissions. Disciplined validation and clean pipelines matter more than chasing leaderboard tenths.
Viability of Mobile Userspace: Tabular cross-validation and standard machine learning workflows run reliably on consumer ARM64 Android devices with tools like Termux and PRoot.
Pocket Data Science Series · Tested on Android 14 / Termux · Debian ARM64 PRoot · Google Antigravity CLI
✦ All scripts (exp01_random_baseline.py through exp08_blend.py) and submissions are archived locally in /root/house-prices/. ✦
Leave a comment