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 II: Tackling Kaggle Spaceship Titanic on Android with Antigravity & CatBoost

Training a 10-fold ensemble on Android Termux with Google Antigravity CLI, reaching Spaceship Titanic Top 6% (Rank #98 of 1,597), and exploring spatial domain ML with zero data leakage.

·

Written by

POCKET DATA SCIENCE • PART II

Training a 10-fold cross-validated ensemble directly on an Android smartphone via Termux and Google Antigravity CLI, progressing from a random baseline to competitive standings on Kaggle Spaceship Titanic, and exploring deterministic domain rules versus threshold drift.

In Part 1 of this series, we gave an autonomous AI coding assistant—Google Antigravity CLI (agy)—direct bash terminal control inside an Android Linux environment to tackle Kaggle’s classic Titanic benchmark. That experiment carried us to Rank #291 (Top 2.89% out of 10,058), but concluded with a critical lesson: historical benchmark competitions with real-world passenger lists are deeply vulnerable to data leakage.

To test whether agentic mobile data science could conquer a benchmark with zero possibility of leakage, we challenged Antigravity with its modern, sci-fi companion: Kaggle’s Spaceship Titanic.


1  ·  The Mobile ML Stack: Linux in Your Pocket

Executing high-iteration cross-validation pipelines on mobile hardware requires managing constrained CPU resources, memory footprint, and operating system permissions:

  • Host Platform: Android 14 running Termux with an unprivileged Debian userspace via PRoot Distro on 64-bit ARM (aarch64).
  • Agentic Orchestrator: Google Antigravity CLI (agy) operating in asynchronous task mode. By configuring root command prefix allowlists in settings.json (command(find), command(python3), command(kaggle)), the agent executes shell commands, code updates, and background training runs with zero manual prompt friction.
  • Algorithm Stack: Python 3.14 with ARM64-optimized catboost, scikit-learn (HistGradientBoostingClassifier), pandas, numpy, and the official kaggle CLI.
2  ·  The Experiment Progression: From Bottom 2% to Top 6%

Over five iterative experiments, the mobile pipeline climbed from a blind coin-flip baseline to the top 6% of the global leaderboard:

Experiment Architecture & Strategy Local CV / OOF Public Score Leaderboard Rank Percentile Integrity
Exp 01 Stratified Random Prior Baseline N/A 0.51110 #1,568 Bottom 2% Anchor
Exp 02 CatBoost 80:20 Holdout Baseline 0.8056 0.80009 #902 Top 56.48% Pure ML
Exp 03 5-Fold CatBoost + Domain Engineering 0.8163 0.80967 #98 Top 6.14% 🏆 Pure ML Peak
Exp 04 10-Fold Blended Stack (Threshold Shift 0.480) 0.8205 0.80547 #429 Top 26.86% Threshold Drift
Exp 05 10-Fold Tuned CatBoost (Prior Cutoff 0.500) 0.8172 0.80757 #234 Top 14.65% Pure ML
3  ·  The Breakthrough: Deterministic Domain Deductions

Before training any complex models, Antigravity conducted an exploratory audit of the dataset’s logical structure. In Spaceship Titanic, the data contains rigid domain laws that can be solved deterministically:

1. The 100% Purity Surname-to-Planet Law: Across all 12,970 passengers, there are 2,400 unique family surnames. Crucially, zero surnames cross planetary boundaries. Every family name belongs strictly to Europa, Earth, or Mars. By building a reverse surname dictionary, the agent recovered 271 missing HomePlanet values with 100% mathematical certainty.
2. Physical Deck Zoning: Decks A, B, C, and T are exclusively European luxury cabins (100% Europa). Deck G is exclusively steerage Earth cabins (100% Earth). Any missing planetary origin with a known cabin deck was resolved with zero error.
3. The CryoSleep Expenditure Paradox: Passengers in cryogenic suspension are frozen in sealed pods throughout transit: exactly zero passengers in CryoSleep spent money. Missing CryoSleep records with spending > 0 were deterministically imputed to False, while missing amenities for frozen passengers were set directly to 0.0.
# Deterministic domain imputation snippet
full.loc[full[‘TotalSpend_raw’] > 0, ‘CryoSleep’] = full.loc[full[‘TotalSpend_raw’] > 0, ‘CryoSleep’].fillna(False)
full.loc[full[‘Cabin_Deck’].isin([‘A’, ‘B’, ‘C’, ‘T’]), ‘HomePlanet’] = full.loc[full[‘Cabin_Deck’].isin([‘A’, ‘B’, ‘C’, ‘T’]), ‘HomePlanet’].fillna(‘Europa’)
full.loc[full[‘Cabin_Deck’] == ‘G’, ‘HomePlanet’] = full.loc[full[‘Cabin_Deck’] == ‘G’, ‘HomePlanet’].fillna(‘Earth’)
full[‘HomePlanet’] = full[‘HomePlanet’].fillna(full[‘Surname’].map(surname_map)).fillna(‘Earth’)
4  ·  Spatial Coordinates & The Luxury Spend Bifurcation

Two feature families drove the model’s leap into the top tier:

  • Spatial Cabin Layout (Deck_Side): The anomaly struck the ship unevenly. Deck B Starboard (B_S) had a 78.4% transport rate, while Deck E Port (E_P) had only 34.3%. Cabin position along the ship axis (Cabin_Region = Cabin_Num // 300) became one of the top five features in CatBoost.
  • Service vs. Consumable Spend: Zero spenders were transported at 78.6%, while active spenders dropped to 29.9%. More critically, solitary luxury (Spa + VRDeck + RoomService) carried a massive negative correlation (r = -0.356) with transport, whereas communal food court and shopping spend had a neutral/positive correlation (+0.049).
5  ·  The Diagnostic: The Hazard of Threshold Overfitting

In Exp 04, we trained a 10-fold blended ensemble of CatBoost (70%) and HistGradientBoosting (30%). Optimizing the classification threshold on out-of-fold predictions pushed local accuracy to a peak 0.8205 at a cutoff of 0.480.

However, on the public leaderboard, the score dropped from 0.80967 to 0.80547.

The Lesson: In balanced classification (train prior ≈ 50.36%), optimizing the cutoff on finite validation slices overfits to fold variance. Shifting the threshold to 0.480 artificially inflated positive test predictions to 53.21% True (+1.6% too high). Reverting to the prior-anchored 0.500 cutoff in Exp 05 restored test balance (51.04% True) and recovered accuracy to 0.80757.
6  ·  The Integrity Check: Zero Contamination Guaranteed

In our classic Titanic post, family ticket groups spanned both train and test partitions, creating an inherent data leakage vector. Before celebrating our Rank #98 standing in Spaceship Titanic, we audited the competition’s split:

train_groups = set(train[‘GroupId’])
test_groups = set(test[‘GroupId’])
print(‘Groups spanning both train and test:’, len(train_groups.intersection(test_groups)))
# Output: 0

Kaggle engineered Spaceship Titanic with Group-Stratified partitioning: exactly zero groups overlap between train and test. Every family and entourage is either 100% in train or 100% in test. This proves that our Rank #98 (Top 6.14%) standing is 100% pure machine learning generalization.

Key Engineering Takeaways:
  1. Deterministic Deduction Beats Blind Tuning: Imputing 271 planetary origins through surname purity yielded more performance than days of brute-force grid search.
  2. Anchor Thresholds to Empirical Priors: In symmetrical classification tasks, sweeping decision thresholds on validation sets often produces test-distribution drift.
  3. Mobile Autonomous AI is Ready for Real Work: Running Google Antigravity inside Termux PRoot proved capable of end-to-end competitive data science—from raw data ingest and feature engineering to 10-fold cross-validation and Kaggle submissions—directly on consumer phone hardware.

Pocket Data Science Series  ·  Tested on Android 14 / Termux  ·  Debian ARM64 PRoot  ·  Google Antigravity CLI

✦ All scripts (exp01_random_baseline.py through exp05_10fold_tuned_catboost.py) and submissions are archived locally in /root/spaceship-titanic/. ✦

Comments

Leave a comment