File size: 2,895 Bytes
ad97490 fc3303a 8c0f157 fc3303a 8c0f157 fc3303a 8c0f157 fc3303a 8c0f157 fc3303a 8c0f157 fc3303a 8c0f157 fc3303a 8c0f157 fc3303a ad97490 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | ---
tags:
- ml-intern
---
# Item Weight Predictor
A machine learning model that predicts the weight (in grams) of items based on their text description. Designed for food delivery platforms to estimate weights for:
- **Menu items** (restaurant food portions)
- **Grocery items** (packaged food from supermarkets)
- **Non-food items** (household goods, electronics, toys, etc.)
## Model Architecture
The model uses **per-item-type Ridge regression** on TF-IDF features of text descriptions:
- Separate models trained for each item category (`menu_item`, `grocery`, `non_food`)
- Log-transformed target to handle wide weight range (grams to kilograms)
- TF-IDF with 1-3 gram features for robust text representation
## Performance
| Item Type | MAE | MAPE | Training Samples | Validation Samples |
|------------|--------|--------|------------------|--------------------|
| Grocery | 23.1g | 4.4% | 17,246 | 3,044 |
| Menu Item | 63.1g | 136.9% | 6,786 | 1,198 |
| Non-Food | 479.9g | 113.6% | 7,152 | 1,263 |
Grocery items perform best because most are standardized to ~100g servings. Menu items and non-food have higher variance but still useful for rough estimates.
## Usage
```python
import joblib
from huggingface_hub import hf_hub_download
# Download and load model
model_path = hf_hub_download(repo_id="ZZandro/weight-predictor", filename="unified_predictor.pkl")
predictor = joblib.load(model_path)
# Predict weight
text = "[MENU_ITEM] grilled chicken breast | food | meal ingredient | portion"
weight_g = predictor.predict(text, item_type="menu_item")
print(f"Predicted weight: {weight_g:.1f}g")
```
### Supported Item Types
- `menu_item` - Restaurant menu items (e.g., "cheeseburger", "caesar salad")
- `grocery` - Packaged grocery products (e.g., "chocolate bar", "cereal box")
- `non_food` - General retail items (e.g., "laptop", "t-shirt", "toy car")
### Text Format
Include the item type tag at the start:
```
[MENU_ITEM] <item description>
[GROCERY] <item description>
[NON_FOOD] <item description>
```
## Data Sources
The training data combines:
- Amazon product data with shipping weights (non-food items)
- NutriBench meal descriptions with per-ingredient gram weights (menu items)
- USDA Foundation Food data with standard serving sizes (grocery items)
## Dataset
The processed training dataset is available at: [ZZandro/item-weight-dataset](https://huggingface.co/datasets/ZZandro/item-weight-dataset)
## License
Apache-2.0
<!-- ml-intern-provenance -->
## Generated by ML Intern
This dataset repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub.
- Try ML Intern: https://smolagents-ml-intern.hf.space
- Source code: https://github.com/huggingface/ml-intern
|