A machine learning project for predicting production values using tabular data and image embeddings. This repository contains the complete pipeline for data preprocessing, feature engineering, model training (CatBoost & Neural Networks), and model explainability.
Datathon-2025/
βββ data/ # Dataset directory (gitignored)
β βββ train.csv # Training data
β βββ test.csv # Test data
β βββ sample_submission.csv # Submission format
β
βββ src/ # Core source modules
β βββ cleaning.py # Data cleaning utilities
β βββ features.py # Feature engineering
β βββ model_training.py # Model training functions
β βββ evaluation.py # Model evaluation metrics
β βββ visualization.py # Plotting and visualization
β
βββ notebooks/ # Jupyter notebooks for EDA & experimentation
β βββ 01_eda_tabular.ipynb # Exploratory analysis (tabular)
β βββ 01_eda_image.ipynb # Exploratory analysis (images)
β βββ 02_modeling_tabular.ipynb
β βββ 02_modeling_image.ipynb
β
βββ scripts/ # Utility scripts
β βββ preprocess_data.py # Data preprocessing
β βββ run_sweep.py # Hyperparameter sweep (W&B)
β βββ import_check.py # Dependency verification
β
βββ reports/ # Streamlit dashboard
β βββ app.py # Interactive model showcase
β
βββ BBDD Output/ # Submission files and logs
β
βββ main.py # Main training pipeline (CatBoost)
βββ 4-Catboost.py # Advanced CatBoost with KNN features
βββ Neural_Network.py # Neural network implementation
βββ sweep.yaml # Weights & Biases sweep configuration
βββ requirements.txt # Python dependencies
- Python 3.8+
- pip
-
Clone the repository:
git clone <repository-url> cd Datathon-2025
-
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # Linux/Mac venv\Scripts\activate # Windows
-
Install dependencies:
pip install -r requirements.txt
-
Add your data: Place your
train.csvandtest.csvfiles in thedata/directory.
The main pipeline performs end-to-end training with CatBoost:
python main.pyThis will:
- Load and clean the data
- Perform feature engineering
- Apply PCA on image embeddings
- Train a CatBoost model with k-fold cross-validation
- Generate predictions and save outputs
For the enhanced CatBoost model with additional KNN features:
python 4-Catboost.pypython Neural_Network.pypython scripts/run_sweep.pyConfigure sweeps in sweep.yaml.
Launch the Streamlit dashboard for model exploration:
streamlit run reports/app.py- Missing value analysis and imputation
- Type conversion and formatting
- Outlier handling
- Preprocessing pipeline
- Categorical encoding
- Numerical transformations
- Parse image embeddings from string format
- Apply PCA dimensionality reduction
- Standard scaling of PCA components
- CatBoost: Gradient boosting with native categorical support
- Neural Network: Deep learning approach with batch normalization and dropout
- Classification metrics (AUC, precision, recall, F1)
- Regression metrics (RMSE)
- SHAP summary plots
- Feature importance
- Cross-validation scores
| Feature | Description |
|---|---|
| PCA on Embeddings | Reduces 512-dimensional image embeddings to configurable components |
| KNN Features | Aggregated target values from nearest neighbors in embedding space |
| Asymmetric Loss | Custom loss function penalizing overprediction 3x in neural network |
| Cross-Validation | Robust k-fold validation with out-of-fold predictions |
| SHAP Explainability | Feature importance and individual prediction explanations |
| W&B Integration | Experiment tracking and hyperparameter sweeps |
After running the pipeline, outputs are saved to:
| File | Description |
|---|---|
output/submission.csv |
Final predictions for submission |
output/oof_predictions.csv |
Out-of-fold predictions for stacking |
output/feature_importance.csv |
Feature importance rankings |
BBDD Output/submissions_log.csv |
Log of all submissions with scores |
Explore the data and experiment with models using the Jupyter notebooks in notebooks/:
01_eda_tabular.ipynb- Tabular data exploration01_eda_image.ipynb- Image embedding analysis02_modeling_tabular.ipynb- Model experimentation02_modeling_image.ipynb- Image-based model experiments
Key libraries used in this project:
- Data Processing:
pandas,numpy - Machine Learning:
scikit-learn,catboost,lightgbm,xgboost - Deep Learning:
tensorflow - Visualization:
matplotlib,seaborn,shap - Experiment Tracking:
wandb - Web App:
streamlit
See requirements.txt for the complete list.
Key parameters in main.py:
RANDOM_STATE = 42
N_FOLDS = 5
METRIC = 'auc' # Use 'rmse' for regression
catboost_params = {
'learning_rate': 0.03,
'depth': 6,
'l2_leaf_reg': 3,
'min_data_in_leaf': 20,
}N_PCA_COMPONENTS = 10 # Number of principal components
EXPECTED_EMBED_DIMS = 512 # Original embedding dimensions- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Open a Pull Request
This project was created for Datathon 2025.
- Datathon Barcelona 2025 organizers
- Weights & Biases for experiment tracking
- SHAP library for model explainability