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
Next Steps
Now that you've mastered end-to-end model development, you might want to explore GPU optimization to make your models run faster and save on compute costs. Check out CUDA Optimization for low-level kernel programming or Triton Optimization for a more accessible approach to GPU acceleration. If you're working with LLMs, Prompt Engineering can help you optimize your prompts for better performance and lower costs.
For more advanced usage and configuration options, visit the CLI Reference or learn about Writing Good Evaluation Scripts to improve your optimization results.