Skip to content

Commit

Permalink
Add test cases for numbers passed as categorical attributes (#36)
Browse files Browse the repository at this point in the history
* accrued changes

* add in tests for explicit categorical

* log the training allocation
  • Loading branch information
aarsilv authored Jun 27, 2024
1 parent a9615d6 commit fff3b42
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 45 deletions.
18 changes: 12 additions & 6 deletions ufc/bandit-flags-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"variationKey": "control",
"shards": []
}
]
],
"doLog": true
}
]
},
Expand All @@ -37,7 +38,8 @@
"variationKey": "control",
"shards": []
}
]
],
"doLog": true
}
]
},
Expand Down Expand Up @@ -79,7 +81,8 @@
}
]
}
]
],
"doLog": false
},
{
"key": "training",
Expand All @@ -93,7 +96,8 @@
}
]
}
]
],
"doLog": true
}
],
"totalShards": 10000
Expand Down Expand Up @@ -127,7 +131,8 @@
"variationKey": "banner_bandit",
"shards": []
}
]
],
"doLog": true
},
{
"key": "default",
Expand All @@ -137,7 +142,8 @@
"variationKey": "control",
"shards": []
}
]
],
"doLog": true
}
],
"totalShards": 10000
Expand Down
22 changes: 20 additions & 2 deletions ufc/bandit-models-v1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"updatedAt": "2023-09-13T04:52:06.462Z",
"bandits": {
"bandits": {
"banner_bandit": {
"banditKey": "banner_bandit",
"modelName": "falcon",
Expand Down Expand Up @@ -30,6 +30,15 @@
"bronze": 1.9
},
"missingValueCoefficient": 0.0
},
{
"attributeKey": "zip",
"valueCoefficients": {
"22203": 5.0,
"94111": -10.0,
"81427": 8.0
},
"missingValueCoefficient": 0.0
}
],
"subjectNumericCoefficients": [
Expand Down Expand Up @@ -79,6 +88,15 @@
"male": 0.3
},
"missingValueCoefficient": 0.45
},
{
"attributeKey": "area_code",
"valueCoefficients": {
"303": 10.0,
"301": 7.0,
"415": -2.0
},
"missingValueCoefficient": 0.0
}
]
}
Expand All @@ -98,4 +116,4 @@
}
}
}
}
}
4 changes: 2 additions & 2 deletions ufc/bandit-tests/test-case-bandit-does-not-exist.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"subjects": [
{
"subjectKey": "alice",
"subjectAttributes": {"numeric_attributes": {"age": 25}, "categorical_attributes": {"country": "USA"}},
"subjectAttributes": {"numericAttributes": {"age": 25}, "categoricalAttributes": {"country": "USA"}},
"actions": [],
"assignment": {"variation": "default", "action": null}
}
]
}
}
2 changes: 1 addition & 1 deletion ufc/bandit-tests/test-case-bandit-no-actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"subjects": [
{
"subjectKey": "alice",
"subjectAttributes": {"numeric_attributes": {"age": 25}, "categorical_attributes": {"country": "USA"}},
"subjectAttributes": {"numericAttributes": {"age": 25}, "categoricalAttributes": {"country": "USA"}},
"actions": [],
"assignment": {"variation": "default", "action": null}
}
Expand Down
30 changes: 15 additions & 15 deletions ufc/bandit-tests/test-case-banner-bandit-uk-only.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
{
"subjectKey": "alice",
"subjectAttributes": {
"numeric_attributes": {"age": 25},
"categorical_attributes": {"country": "USA", "gender_identity": "female"}
"numericAttributes": {"age": 25},
"categoricalAttributes": {"country": "USA", "gender_identity": "female"}
},
"actions": [
{
Expand All @@ -31,8 +31,8 @@
{
"subjectKey": "bob",
"subjectAttributes": {
"numeric_attributes": {"age": 30, "account_age": 10},
"categorical_attributes": {"country": "UK", "gender_identity": "male"}
"numericAttributes": {"age": 30, "account_age": 10},
"categoricalAttributes": {"country": "UK", "gender_identity": "male"}
},
"actions": [
{
Expand All @@ -57,8 +57,8 @@
{
"subjectKey": "charlie",
"subjectAttributes": {
"numeric_attributes": {"age": 50, "account_age": 2},
"categorical_attributes": {"country": "Canada", "gender_identity": "unknown"}
"numericAttributes": {"age": 50, "account_age": 2},
"categoricalAttributes": {"country": "Canada", "gender_identity": "unknown"}
},
"actions": [
{
Expand All @@ -83,8 +83,8 @@
{
"subjectKey": "debra",
"subjectAttributes": {
"numeric_attributes": {"age": 28, "account_age": 30},
"categorical_attributes": {"country": "UK", "gender_identity": "unknown"}
"numericAttributes": {"age": 28, "account_age": 30},
"categoricalAttributes": {"country": "UK", "gender_identity": "unknown"}
},
"actions": [
{
Expand All @@ -109,8 +109,8 @@
{
"subjectKey": "erica",
"subjectAttributes": {
"numeric_attributes": {"age": 28, "account_age": 30},
"categorical_attributes": {"country": "USA", "gender_identity": "female"}
"numericAttributes": {"age": 28, "account_age": 30},
"categoricalAttributes": {"country": "USA", "gender_identity": "female"}
},
"actions": [
{
Expand Down Expand Up @@ -145,8 +145,8 @@
{
"subjectKey": "frenkie",
"subjectAttributes": {
"numeric_attributes": {"age": 31, "account_age": 4},
"categorical_attributes": {"country": "Netherlands", "gender_identity": "male"}
"numericAttributes": {"age": 31, "account_age": 4},
"categoricalAttributes": {"country": "Netherlands", "gender_identity": "male"}
},
"actions": [
{
Expand Down Expand Up @@ -180,8 +180,8 @@
{
"subjectKey": "gerard",
"subjectAttributes": {
"numeric_attributes": {"age": null},
"categorical_attributes": {"country": null, "gender_identity": null}
"numericAttributes": {"age": null},
"categoricalAttributes": {"country": null, "gender_identity": null}
},
"actions": [
{
Expand Down Expand Up @@ -213,4 +213,4 @@
"assignment": {"variation": "control", "action": null}
}
]
}
}
80 changes: 65 additions & 15 deletions ufc/bandit-tests/test-case-banner-bandit.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
{
"subjectKey": "alice",
"subjectAttributes": {
"numeric_attributes": {"age": 25},
"categorical_attributes": {"country": "USA", "gender_identity": "female"}
"numericAttributes": {"age": 25},
"categoricalAttributes": {"country": "USA", "gender_identity": "female"}
},
"actions": [
{
Expand All @@ -31,8 +31,8 @@
{
"subjectKey": "bob",
"subjectAttributes": {
"numeric_attributes": {"age": 30, "account_age": 10},
"categorical_attributes": {"country": "UK", "gender_identity": "male"}
"numericAttributes": {"age": 30, "account_age": 10},
"categoricalAttributes": {"country": "UK", "gender_identity": "male"}
},
"actions": [
{
Expand All @@ -57,8 +57,8 @@
{
"subjectKey": "charlie",
"subjectAttributes": {
"numeric_attributes": {"age": 50, "account_age": 2},
"categorical_attributes": {"country": "UK", "gender_identity": "unknown"}
"numericAttributes": {"age": 50, "account_age": 2},
"categoricalAttributes": {"country": "UK", "gender_identity": "unknown"}
},
"actions": [
{
Expand All @@ -83,8 +83,8 @@
{
"subjectKey": "debra",
"subjectAttributes": {
"numeric_attributes": {"age": 28, "account_age": 30},
"categorical_attributes": {"country": "Canada", "gender_identity": "unknown"}
"numericAttributes": {"age": 28, "account_age": 30},
"categoricalAttributes": {"country": "Canada", "gender_identity": "unknown"}
},
"actions": [
{
Expand All @@ -109,8 +109,8 @@
{
"subjectKey": "erica",
"subjectAttributes": {
"numeric_attributes": {"age": 28, "account_age": 30},
"categorical_attributes": {"country": "USA", "gender_identity": "female"}
"numericAttributes": {"age": 28, "account_age": 30},
"categoricalAttributes": {"country": "USA", "gender_identity": "female"}
},
"actions": [
{
Expand Down Expand Up @@ -145,8 +145,8 @@
{
"subjectKey": "frenkie",
"subjectAttributes": {
"numeric_attributes": {"age": 31, "account_age": 4},
"categorical_attributes": {"country": "Netherlands", "gender_identity": "male"}
"numericAttributes": {"age": 31, "account_age": 4},
"categoricalAttributes": {"country": "Netherlands", "gender_identity": "male"}
},
"actions": [
{
Expand Down Expand Up @@ -180,8 +180,8 @@
{
"subjectKey": "gerard",
"subjectAttributes": {
"numeric_attributes": {"age": null},
"categorical_attributes": {"country": null, "gender_identity": null}
"numericAttributes": {"age": null},
"categoricalAttributes": {"country": null, "gender_identity": null}
},
"actions": [
{
Expand Down Expand Up @@ -211,6 +211,56 @@
}
],
"assignment": {"variation": "banner_bandit", "action": "nike"}
},
{
"subjectKey": "henry",
"subjectAttributes": {
"numericAttributes": { "age": 25, "mistake": "oops" },
"categoricalAttributes": {"country": "USA", "gender_identity": "female", "area_code": 303}
},
"actions": [
{
"actionKey": "nike",
"numericAttributes": {"brand_affinity": -5},
"categoricalAttributes": {"loyalty_tier": "silver"}
},
{
"actionKey": "adidas",
"numericAttributes": {"brand_affinity": 1.0},
"categoricalAttributes": {"loyalty_tier": "bronze"}
},
{
"actionKey": "reebok",
"numericAttributes": {"brand_affinity": 20},
"categoricalAttributes": {"loyalty_tier": "gold"}
}
],
"assignment": {"variation": "banner_bandit", "action": "adidas"}
},
{
"subjectKey": "imogene",
"subjectAttributes": {
"numericAttributes": { "age": 25},
"categoricalAttributes": {"country": "USA", "gender_identity": "female"}
},
"actions": [
{
"actionKey": "nike",
"numericAttributes": {"brand_affinity": -1.7, "mistake": true},
"categoricalAttributes": {"loyalty_tier": "silver", "zip": 81427}
},
{
"actionKey": "adidas",
"numericAttributes": {"brand_affinity": 1.0},
"categoricalAttributes": {"loyalty_tier": "bronze"}
},
{
"actionKey": "reebok",
"numericAttributes": {"brand_affinity": 15},
"categoricalAttributes": {"loyalty_tier": "gold"}
}
],
"assignment": {"variation": "banner_bandit", "action": "nike"}
}
]
}
}
4 changes: 2 additions & 2 deletions ufc/bandit-tests/test-case-non-bandit-flag.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"subjects": [
{
"subjectKey": "alice",
"subjectAttributes": {"numeric_attributes": {"age": 25}, "categorical_attributes": {"country": "USA"}},
"subjectAttributes": {"numericAttributes": {"age": 25}, "categoricalAttributes": {"country": "USA"}},
"actions": [],
"assignment": {"variation": "control", "action": null}
}
]
}
}
4 changes: 2 additions & 2 deletions ufc/bandit-tests/test-case-non-bandit-integer-flag.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"subjects": [
{
"subjectKey": "alice",
"subjectAttributes": {"numeric_attributes": {"age": 25}, "categorical_attributes": {"country": "USA"}},
"subjectAttributes": {"numericAttributes": {"age": 25}, "categoricalAttributes": {"country": "USA"}},
"actions": [],
"assignment": {"variation": "default", "action": null}
}
]
}
}

0 comments on commit fff3b42

Please sign in to comment.