Model Development (Kaggle Spaceship Titanic)
Iteratively improve a model's accuracy on Kaggle's Spaceship Titanic
This example demonstrates using Weco to optimize a Python script designed for the Spaceship Titanic Kaggle competition.
The goal is to improve the model's accuracy
metric by optimizing the train.py
You can find the complete files for this example here.
Setup
-
Ensure you are in the
examples/spaceship-titanic
directory. -
Install Dependencies: Install the required Python packages:
-
Choose your LLM provider:
Create your OpenAI API key here.
Create the Optimization Target
This script contains the train_model
and predict_with_model
functions. Weco only edits this file during the run.
Create the Evaluation Script
This script evaluates the generated dataframe. It will read train and test from data folder and add a validation dataset for intermediate evaluation (optimization target). And it will generate a submission.csv
at the end.
Run Weco
Run the following command to start optimizing the model:
Explanation
--source train.py
: The script provides a baseline as root node and directly optimize the train.py--eval-command "python evaluate.py --data-dir ./data/"
: The weco agent will run theevaluate.py
.- [optional]
--data-dir
: path to the train and test data. - [optional]
--seed
: Seed for reproduce the experiment.
- [optional]
--metric accuracy
: The target metric Weco should optimize.--goal maximize
: Weco aims to increase the accuracy.--steps 10
: The number of optimization iterations.--model o4-mini
: The LLM driving the optimization.--additional-instructions "Improve feature engineering, model choice and hyper-parameters."
: A simple instruction for model improvement or you can put the path tocomptition_description.md
within the repo to feed the agent more detailed information.--log-dir .runs/spaceship-titanic
: Specifies the directory where Weco should save logs and results for this run.
Weco will iteratively update the feature engineering or modeling code within train.py
guided by the evaluation method defined in evaluate.py
What's Next?
- GPU optimization: Try CUDA or Triton to make models run faster
- Different optimization types: Explore PyTorch Optimization or Prompt Engineering
- Better evaluation scripts: Learn Writing Good Evaluation Scripts
- All command options: Check the CLI Reference