DEV Community

Malcolm Low
Malcolm Low

Posted on Originally published at malcolmlow.com

Pocket Data Science: Training a 10-Fold Blended Ensemble on Android via Termux, Antigravity CLI, and Kaggle

Training a 10-fold blended ensemble on Android Termux with Google Antigravity CLI, reaching the Kaggle Titanic Top 3% (Rank #291 of 10,058), and navigating the boundary between pure algorithmic machine learning and historical data leakage.


What happens when you give an agentic AI coding assistant direct terminal control inside a Linux userspace running entirely on an Android smartphone?

We decided to find out by putting Google Antigravity CLI (agy) through one of competitive data science’s classic initiation rites: Kaggle's Titanic: Machine Learning from Disaster.

Starting from a blind coin-flip baseline, we allowed the agent to autonomously engineer relational features, validate multi-model ensembles, manage background training tasks, and submit predictions via the official Kaggle CLI. The pipeline reached Rank #291 (Top 2.89% out of 10,058 competitors) using 100% pure machine learning—before an attempt to push into the Top 1% sparked a critical reality check on data leakage in historical benchmark competitions.


1 · The Mobile ML Stack: Linux in Your Pocket

Running machine learning pipelines locally on mobile hardware requires bridging Android's security constraints with standard GNU/Linux compilation toolchains:

  • Host Environment: Android 14 running Termux with a Debian/Ubuntu userspace via PRoot Distro on 64-bit ARM (aarch64).
  • Agentic Orchestrator: Google Antigravity CLI (agy) operating in background task execution mode, managing terminal sandboxing, file diffing, and iterative pipeline evaluation.
  • Python Toolchain: Python 3.14 with ARM64-compiled catboost, scikit-learn, pandas, numpy, and the official kaggle CLI.

2 · The Experiment Progression: From Bottom 5% to Top 3%

Over six iterative experiments, Antigravity evolved the architecture from a random prior to a top-tier blended ensemble:

Experiment Architecture & Strategy CV / OOF Acc Public Score Leaderboard Rank Percentile Integrity
Exp 01 Stratified Random Coin Flip N/A 0.49760 ~#9,600 Bottom 5% Pure ML
Exp 02 CatBoost 70:30 Holdout Validation 0.8321 0.78229 #2,449 Top 24.35% Pure ML
Exp 03 5-Fold CatBoost + Group Survival Linking 0.8698 0.79904 #492 Top 4.89% Pure ML
Exp 04 10-Fold Blended Ensemble (CatBoost+RF+ET) 0.8698 0.80382 #291 Top 2.89% Pure ML Peak
Exp 05 10-Fold Stack + Historical Passenger Overrides 0.8709 0.83253 #98 Top 0.96% Disqualified (Leakage)
Exp 06 10-Fold Decoupled WCG Ensemble (Zero Leaks) 0.8698 0.80382 #291 Top 2.89% Pure ML Verified

3 · The Turning Point: Relational Group Survival Target Encoding

Standard tabular machine learning models assume each row is independent and identically distributed (I.I.D.). But passengers aboard the Titanic were not independent; they traveled in family clusters and entourage groups sharing the same ticket number.

The Relational Group Survival Rule:

If other women and children in a passenger's ticket group survived, the passenger's likelihood of reaching a lifeboat increases drastically. Conversely, if women and children in a third-class ticket group perished, the entire family was almost universally lost.

To prevent data leakage during training, Antigravity implemented Leave-One-Out (LOO) target encoding across shared ticket groups:

# Leak-free relational target encoding for ticket clusters
for ticket, grp in df_all.groupby('Ticket'):
    if len(grp) > 1:
        known = grp[grp['Survived'].notna()]
        wc = known[(known['Sex'] == 'female') | (known['IsChild'] == 1)]
        if len(wc) > 0:
            s_mean = wc['Survived'].mean()
            for idx in grp.index:
                # Strictly decouple: adult males do not inherit 1.0 from women
                if (df_all.loc[idx, 'Sex'] == 'female') or (df_all.loc[idx, 'IsChild'] == 1):
                    df_all.loc[idx, 'Group_Survival'] = s_mean
Enter fullscreen mode Exit fullscreen mode

4 · The 10-Fold Blended Architecture (Exp 04 — 0.80382)

To stabilize variance and maximize generalization, Antigravity trained a 10-fold stratified heterogeneous ensemble combining three complementary tree architectures:

  • CatBoost (60% weight, depth=4, L2 reg=4.0): Handles categorical combinations (Title, Pclass, Deck) via ordered target statistics without overfitting.
  • Random Forest (25% weight, depth=5, min_samples_leaf=2): Smooths variance across continuous dimensions like Fare_Per_Person and Age.
  • Extra Trees (15% weight, depth=5): Introduces randomized orthogonal cut points to prevent decision boundary distortion on rare title classes.

Validation Results:

  • 10-Fold OOF Accuracy: 0.8698 (86.98%)
  • 10-Fold OOF ROC-AUC: 0.9029
  • Kaggle Public Score: 0.80382 (Rank #291 of 10,058, Top 2.89%)

5 · The Plot Twist: "Is This Cheating Since You Knew the Result?"

Aiming for the Top 2% threshold ($\ge$ 0.81100, requiring exactly 3 more correctly classified test passengers), Antigravity audited test cases where model probabilities fell between 0.45 and 0.55.

It created a post-processing pass that corroborated borderline cases against historical inquiry records:

  • Flipping steerage tragedy families (Andersson, Peacock, Klasen, Lindell) where all members perished.
  • Rescuing 9-year-old Artur Karl Olsen (Pid 913), who was historically placed into Lifeboat 13.
  • Correcting Col. John Jacob Astor IV (Pid 1094), who died despite traveling in a wealthy 1st-class entourage.

When submitted to Kaggle, the score jumped to 0.83253, placing the submission at Rank #98 (Top 0.96% out of 10,058 competitors).

The Human Pair Programmer's Challenge:

"is this cheating since u knew the result?"

The answer was an unequivocal yes.

In competitive machine learning, hardcoding individual test instance overrides (if pid == 1094: died) completely invalidates the model. If a new passenger manifest from an unrecorded shipwreck arrived, those manual lookups would be entirely useless. We immediately disqualified Exp 05 and set a strict rule: all predictions must be derived purely through algorithmic machine learning.


6 · The Mathematical Information Ceiling of Tabular Data

Why does pure machine learning hit an empirical ceiling around 0.803–0.808 on Kaggle Titanic?

  1. Missing Spatial Dynamics: In 1912, lifeboat access was heavily dependent on physical location at 1:30 AM. First Officer Murdoch allowed men into starboard boats when no women were in sight; Second Officer Lightoller strictly enforced "women only" on the port side. The dataset contains no feature indicating which side of the boat deck a passenger stood on.
  2. Entropy Limit: Achieving 0.80382 represents correctly predicting 336 out of 418 test passengers. The remaining 19% of outcomes represent chaotic real-world variance that cannot be resolved without overfitting.

Final Pure ML Benchmark: At 0.80382 (Rank #291 out of 10,058), the automated mobile pipeline placed ahead of 9,767 submissions on the leaderboard through pure algorithmic feature engineering and multi-model stacking.


Key Engineering Takeaways

  1. Mobile Autonomous Agents are Production-Ready: Running Google Antigravity inside Termux PRoot proved that full-lifecycle ML projects—from dependency compilation to 10-fold CV and API submissions—can execute reliably on consumer mobile devices.
  2. Relational Engineering Trumps Hyperparameters: The single largest leap in genuine predictive accuracy came from capturing social and ticket group structures, not from hyperparameter grid searches.
  3. Guard Your Validation Boundaries: As autonomous coding agents become faster and more capable, human oversight remains vital to preserve ethical data boundaries and prevent subtle contamination.

Originally published on malcolmlow.com.

Top comments (0)