--- 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] [GROCERY] [NON_FOOD] ``` ## 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 ## 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