Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle bandit parameter coefficients provided as maps (Objects) #57

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>cloud.eppo</groupId>
<artifactId>eppo-server-sdk</artifactId>
<version>2.4.5</version>
<version>2.4.6</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>Eppo Server-Side SDK for Java</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ public Map<String, BanditParameters> deserialize(
JsonNode coefficientsNode = modelDataNode.get("coefficients");

Map<String, BanditCoefficients> coefficients = new HashMap<>();
coefficientsNode.iterator().forEachRemaining(actionCoefficientsNode -> {
BanditCoefficients actionCoefficients = this.parseActionCoefficientsNode(actionCoefficientsNode);
coefficients.put(actionCoefficients.getActionKey(), actionCoefficients);
Iterator<Map.Entry<String, JsonNode>> coefficientIterator = coefficientsNode.fields();
coefficientIterator.forEachRemaining(field -> {
BanditCoefficients actionCoefficients = this.parseActionCoefficientsNode(field.getValue());
coefficients.put(field.getKey(), actionCoefficients);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while we're leaving actionKey in the action coefficients for now, that is redundant and may be later removed, so I don't want to count on it being there and instead use the Object key as the action key.

});

modelData.setCoefficients(coefficients);
Expand Down
10 changes: 5 additions & 5 deletions src/test/resources/bandits/bandits-parameters-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"gamma": 1.0,
"defaultActionScore": 0.0,
"actionProbabilityFloor": 0.0,
"coefficients": [
{
"coefficients": {
"nike": {
"actionKey": "nike",
"intercept": 1.0,
"actionNumericCoefficients": [
Expand Down Expand Up @@ -50,7 +50,7 @@
}
]
},
{
"adidas": {
"actionKey": "adidas",
"intercept": 1.1,
"actionNumericCoefficients": [
Expand Down Expand Up @@ -82,7 +82,7 @@
}
]
}
]
}
}
},
{
Expand All @@ -94,7 +94,7 @@
"gamma": 1.0,
"defaultActionScore": 0.0,
"actionProbabilityFloor": 0.0,
"coefficients": []
"coefficients": {}
}
}
]
Expand Down