Team: Gemini
This project aims to solve the Smart Product Pricing Challenge by developing a machine learning solution to predict product prices based on their catalog information, including textual descriptions and images. The goal is to create a model that can holistically analyze product details and suggest an optimal price, minimizing the Symmetric Mean Absolute Percentage Error (SMAPE).
student_resource/main.py: The main script to run the entire pipeline, including data processing, model training, and prediction.student_resource/src/data_processor.py: Contains theDataProcessorclass, which handles data loading, cleaning, and feature engineering.student_resource/src/model_trainer.py: Contains theXGBModelTrainerandTorchModelTrainerclasses for training the XGBoost and PyTorch models.student_resource/src/predictor.py: Contains thePredictorclass, which is used to generate the final submission file.student_resource/dataset/: This directory contains the training and test data.student_resource/downloaded_images/: This directory contains the downloaded product images.submission.csv: The final submission file generated by the pipeline.
To run this project, you need to install the following libraries:
numpy
pandas
tqdm
scikit-learn
torch
torchvision
xgboost
Pillow
You can install them using pip:
pip install numpy pandas tqdm scikit-learn torch torchvision xgboost PillowTo run the complete training and prediction pipeline, execute the following command:
python student_resource/main.pyYou can adjust the hyperparameters for the models by passing command-line arguments.
| Argument | Type | Default | Description |
|---|---|---|---|
--hidden_dim |
int | 256 | Hidden dimension for the NN model. |
--dropout_rate |
float | 0.5 | Dropout rate for the NN model. |
--lr |
float | 1e-4 | Learning rate for the NN model. |
--epochs |
int | 30 | Number of epochs to train the NN model. |
--patience |
int | 5 | Early stopping patience. |
--xgb_estimators |
int | 1000 | Number of estimators for XGBoost. |
For example:
python student_resource/main.py --xgb_estimators 1500 --hidden_dim 512 --lr 1e-3This project has implemented a complete pipeline for predicting product prices. The pipeline includes data processing, feature engineering, model training, and evaluation. Two models, an XGBoost model and a PyTorch-based neural network, have been developed and are combined using an ensemble approach.
The solution follows a structured machine learning workflow:
-
Data Processing: The
DataProcessorclass insrc/data_processor.pyhandles loading the training and test data. -
Feature Engineering:
- Text Features: The
catalog_contentis cleaned, and TF-IDF features (unigrams and bigrams) are extracted. The Item Pack Quantity (IPQ) is also extracted as a separate feature. - Image Features: A pre-trained ResNet-50 model is used to extract features from the product images.
- Text Features: The
-
Modeling:
- XGBoost: An XGBoost model is trained on the combined features.
- PyTorch NN: A feed-forward neural network is also trained on the same features.
- Ensemble: The predictions from both models are combined using a weighted average, with the weights optimized on a validation set.
-
Prediction: The final predictions are generated, and a submission file is created.
The following SMAPE scores were achieved on the validation set. Please note that these are example scores and may vary based on the training data and hyperparameters.
- XGBoost Model: ~52.58
- PyTorch NN Model: ~58.75
- Ensemble Model (Weighted): ~55.60
- More Advanced Feature Engineering: Extracting more specific features from the text, such as brand names, product specifications, or sentiment, could provide a strong signal to the models.
- Fine-tuning Image Models: Instead of using a fixed feature extractor, fine-tuning the ResNet-50 model (or a more modern architecture like EfficientNet) on the product images could yield more domain-specific and powerful image features.
- Advanced Text Models: Using transformer-based models like BERT to generate text embeddings could capture a much deeper semantic understanding of the product descriptions compared to TF-IDF.
- Stacking Ensemble: A more advanced ensembling technique like stacking, where a meta-model is trained on the predictions of the base models, could further improve the final prediction accuracy.