Evolving a Farmer: Building an Agent to Play Kaggriculture
Kaggriculture is a different kind of Kaggle competition. There is no dataset to download and no CSV to submit. You submit an agent: a Python function that, each turn, receives the state of a two-player farming sim and returns actions like buy seeds, plant, water, harvest, raise animals, trade on the market. Over a 30-day season of 720 turns, whoever has the most money in the bank wins. Your agent is scored by playing games against everyone else’s.
Labels Are the Ceiling: Building a Knee MRI Model on 100GB You Never Download
The RSNA Knee Abnormality Detection competition is a different animal from the tabular problems I usually work. The task sounds simple: predict 12 binary findings per knee MRI study (ACL tear, meniscus, effusion, fracture, and so on), scored by macro-averaged ROC AUC. The reality is harder:
- 4,407 studies, 24,371 series, roughly 820,000 DICOM slices, 100GB+.
- You do not download any of it. The data is mounted inside a Kaggle notebook and you train on Kaggle’s GPU.
- Only 58 of the 4,407 studies are expert-labeled. The rest come with a free-text radiology report, in a dozen languages.
So before writing a model, I wanted to answer one question: can I even reach the data, read it, and get a valid submission accepted? If that plumbing does not work, a fancy model is worthless.
Research First: Beating Kaggle's Titanic with History Books
Most Kaggle Titanic tutorials open with
import pandas as pdand immediately start running.describe(). I did something different: I read about the actual disaster first.The result was better feature engineering, more informed imputation strategies, and a clearer picture of what was noise versus signal. The model barely mattered. The features did all the work.
Why Research Before Code
The Titanic dataset has 891 rows and 11 features. You could get ~77% accuracy by predicting “all women survive, all men die.” Getting past 77% requires understanding why people survived beyond gender. That understanding comes from the history, not the data.
Who Was Aboard the Titanic? Clustering Passengers (and Testing Whether It Helps Prediction)
Everyone who has ever touched a Kaggle dataset has tried to predict who survived the Titanic. It’s the “Hello World” of machine learning: load the data, tune a model, submit a CSV, feel clever. I wanted to ask a different question.
Not “who survived?” but Seinfeld’s age-old question of “who are these people?”
Prediction treats the passengers as rows in a matrix. Clustering treats them as human beings who fall into natural groups: the wealthy elite, young workers, immigrant families, people traveling alone. Those groups fall out of the data on their own, without anyone labeling them. Then you overlay survival on top and the story gets a lot more human than any accuracy score.
How Kaggle submissions actually work (CSV, code comps, and not wasting your daily budget)
Submitting to Kaggle sounds trivial until your first CSV gets rejected for a reason the error message won’t explain. Here’s how the two formats work and how not to burn your limited daily submissions on nothing.
CSV submissions
Most competitions want a CSV with an ID column and one or more prediction columns. Titanic, for example:
PassengerId,Survived 892,0 893,1 894,0 ...The rules that actually bite:
- Column names have to match the sample submission file exactly.
- Row count has to equal the test set. Not one more, not one fewer.
- No extra columns, and no index column (this is the one that gets everyone).
Code Competition submissions
Some competitions make you submit a notebook that generates predictions at runtime instead of a finished CSV. In those:
Getting the Kaggle CLI working without the usual headaches
Doing Kaggle from the terminal instead of clicking around the website is so much nicer once it’s set up, but the first-time setup has a couple of spots that trip everyone (me included). Here’s the whole thing, including the errors you’ll probably hit.
Install it
pip install kaggleThat gives you the
kagglecommand for pulling data, submitting predictions, and browsing competitions without leaving the terminal.Hook up your credentials
- Log in at kaggle.com/settings
- Find the API section and click Create New Token
- A
kaggle.jsonfile downloads. That’s your credentials, so don’t commit it anywhere. - Move it where the CLI expects:
- Linux/macOS:
~/.kaggle/kaggle.json - Windows:
C:\Users\<username>\.kaggle\kaggle.json
- Linux/macOS:
- On Linux/macOS, lock down the permissions:
chmod 600 ~/.kaggle/kaggle.json
The commands you’ll actually use
Command What it does kaggle competitions listBrowse active competitions kaggle competitions download -c titanicDownload competition data kaggle competitions submit -c titanic -f submission.csv -m "message"Submit predictions kaggle competitions submissions -c titanicSee your submission history kaggle datasets list -s "keyword"Search public datasets When it breaks (and it will, once)
- “Could not find kaggle.json”: the file isn’t in
~/.kaggle/(or%USERPROFILE%\.kaggle\on Windows). That’s almost always it. - “403 Forbidden”: you haven’t accepted the competition rules on the website yet. Go click the button, then try again.
- “401 Unauthorized”: your API token expired or got revoked. Regenerate it and swap in the new
kaggle.json. - Timeouts: usually just the Kaggle API having a slow moment. Check your connection and retry.
If you want to confirm everything’s wired up, run
python scripts/verify_kaggle_cli.pyand it’ll check the setup for you.Building an AI-Assisted Kaggle Toolkit
I got tired of the standard Kaggle workflow. Open a notebook, import pandas, start typing
.describe(), throw some models at the wall. It works, but you don’t learn much, and three months later you can’t remember why you chose XGBoost over Random Forest.So I built a toolkit that forces a better process: research first, then model. Document everything. Produce educational content as a natural byproduct of doing the work.