Spaces:
Runtime error
Runtime error
| # π― Automatic Value Mapping - Update Complete | |
| ## β What Was Implemented | |
| The A/B Test Predictor API now supports **automatic value mapping** for three key inputs: | |
| 1. **Industry** - Converts 339 specific industries to 14 parent groups | |
| 2. **Page Type** - Converts 43 specific page types to 5 parent groups | |
| 3. **Conversion Type** - Converts 16 specific conversion types to 6 parent groups | |
| ## π How It Works | |
| ### Before This Update: | |
| ```python | |
| # You HAD to use parent groups | |
| result = client.predict( | |
| "control.jpg", "variant.jpg", | |
| "SaaS", "B2B", | |
| "High-Intent Lead Gen", # Parent group (required) | |
| "B2B Software & Tech", # Parent group (required) | |
| "Awareness & Discovery", # Parent group (required) | |
| api_name="/predict_with_categorical_data" | |
| ) | |
| ``` | |
| ### After This Update: | |
| ```python | |
| # You CAN NOW use specific values | |
| result = client.predict( | |
| "control.jpg", "variant.jpg", | |
| "SaaS", "B2B", | |
| "Request Demo/Contact Sales", # Specific value β¨ | |
| "Cybersecurity", # Specific value β¨ | |
| "Homepage", # Specific value β¨ | |
| api_name="/predict_with_categorical_data" | |
| ) | |
| # API automatically converts to: | |
| # "Request Demo/Contact Sales" β "High-Intent Lead Gen" | |
| # "Cybersecurity" β "B2B Software & Tech" | |
| # "Homepage" β "Awareness & Discovery" | |
| ``` | |
| ## π Response Format | |
| The API now returns both the original values you provided AND the grouped values used by the model: | |
| ```json | |
| { | |
| "predictionResults": { ... }, | |
| "providedCategories": { | |
| "industry": "Cybersecurity", | |
| "pageType": "Homepage", | |
| "conversionType": "Request Demo/Contact Sales" | |
| }, | |
| "groupedCategories": { | |
| "industry": "B2B Software & Tech", | |
| "pageType": "Awareness & Discovery", | |
| "conversionType": "High-Intent Lead Gen" | |
| }, | |
| "processingInfo": { ... } | |
| } | |
| ``` | |
| ## π Files Modified | |
| 1. **`app.py`** | |
| - Added `load_value_mappings()` function | |
| - Added `convert_to_parent_group()` function | |
| - Updated `predict_with_categorical_data()` to handle mapping | |
| - Added `get_all_possible_values()` helper function | |
| - Enhanced response to include both provided and grouped categories | |
| 2. **`API_DOCUMENTATION.md`** | |
| - Added "π Automatic Value Mapping" section | |
| - Updated category value lists with examples | |
| - Updated response format documentation | |
| - Added mapping examples and use cases | |
| 3. **`mapping.json`** | |
| - Already existed, now actively used by the API | |
| - Contains all 339 industries, 43 page types, 16 conversion types | |
| ## π§ͺ Testing | |
| Created test files to verify functionality: | |
| - `test_mapping_feature.py` - Unit tests (7/7 passed β ) | |
| - `COMPLETE_EXAMPLE_WITH_MAPPING.py` - Usage examples and demos | |
| ## β¨ Benefits | |
| 1. **More Flexible**: Accept 339+ specific values instead of just 14 parent groups | |
| 2. **Easier Integration**: Use your existing categorization system | |
| 3. **Backward Compatible**: Parent groups still work exactly as before | |
| 4. **Transparent**: See both original and mapped values in response | |
| 5. **Automatic**: No preprocessing needed on your end | |
| ## π Supported Values | |
| | Category | Parent Groups | Specific Values | Examples | | |
| |----------|--------------|----------------|----------| | |
| | Industry | 14 | 339 | "Accounting Services", "Cybersecurity", "Healthcare" | | |
| | Page Type | 5 | 43 | "Homepage", "Pricing Page", "Checkout" | | |
| | Conversion Type | 6 | 16 | "Request Demo", "Buy Now", "Download Asset" | | |
| ## π Example Mappings | |
| **Industry:** | |
| - `Accounting Services` β `B2B Services` | |
| - `Cybersecurity` β `B2B Software & Tech` | |
| - `Healthcare` β `Health & Wellness` | |
| **Page Type:** | |
| - `Homepage` β `Awareness & Discovery` | |
| - `Pricing Page` β `Consideration & Evaluation` | |
| - `Checkout` β `Conversion` | |
| **Conversion Type:** | |
| - `Request Demo/Contact Sales` β `High-Intent Lead Gen` | |
| - `Buy Now` β `Direct Purchase` | |
| - `Download Asset / App` β `Info/Content Lead Gen` | |
| ## π Documentation | |
| - **API Documentation**: See `API_DOCUMENTATION.md` | |
| - **Detailed Summary**: See `MAPPING_UPDATE_SUMMARY.md` | |
| - **Complete Examples**: See `COMPLETE_EXAMPLE_WITH_MAPPING.py` | |
| - **Unit Tests**: See `test_mapping_feature.py` | |
| - **Mapping Data**: See `mapping.json` | |
| ## π Deployment | |
| - **Status**: Ready to deploy β | |
| - **Breaking Changes**: None (fully backward compatible) | |
| - **Requirements**: `mapping.json` must be present in root directory | |
| - **Version**: API v1.1 | |
| ## β οΈ Important Notes | |
| 1. **Values are case-sensitive**: "Cybersecurity" works, "cybersecurity" doesn't | |
| 2. **Exact matches required**: Use exact strings from `mapping.json` | |
| 3. **Unknown values**: Will be passed through as-is (with warning logged) | |
| 4. **Business Model & Customer Type**: Not mapped (no changes needed) | |
| ## π Ready to Use | |
| The update is complete and tested. The API now accepts both specific and parent group values, making it much more flexible and easier to integrate with your existing systems! | |
| --- | |
| **Updated**: October 31, 2025 | |
| **Version**: 1.1 | |
| **Backward Compatible**: Yes β | |