Spaces:
Runtime error
Runtime error
File size: 4,992 Bytes
5b49b49 | 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | # π― 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 β
|