Spaces:
Runtime error
Runtime error
A newer version of the Gradio SDK is available:
6.5.1
π― Automatic Value Mapping - Update Complete
β What Was Implemented
The A/B Test Predictor API now supports automatic value mapping for three key inputs:
- Industry - Converts 339 specific industries to 14 parent groups
- Page Type - Converts 43 specific page types to 5 parent groups
- Conversion Type - Converts 16 specific conversion types to 6 parent groups
π How It Works
Before This Update:
# 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:
# 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:
{
"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
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
- Added
API_DOCUMENTATION.md- Added "π Automatic Value Mapping" section
- Updated category value lists with examples
- Updated response format documentation
- Added mapping examples and use cases
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
- More Flexible: Accept 339+ specific values instead of just 14 parent groups
- Easier Integration: Use your existing categorization system
- Backward Compatible: Parent groups still work exactly as before
- Transparent: See both original and mapped values in response
- 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 ServicesCybersecurityβB2B Software & TechHealthcareβHealth & Wellness
Page Type:
HomepageβAwareness & DiscoveryPricing PageβConsideration & EvaluationCheckoutβConversion
Conversion Type:
Request Demo/Contact SalesβHigh-Intent Lead GenBuy NowβDirect PurchaseDownload 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.jsonmust be present in root directory - Version: API v1.1
β οΈ Important Notes
- Values are case-sensitive: "Cybersecurity" works, "cybersecurity" doesn't
- Exact matches required: Use exact strings from
mapping.json - Unknown values: Will be passed through as-is (with warning logged)
- 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 β