Repository navigation
Align get_treatment_costs columns with the conditions it returns - #1065
Open
arpitjain099 wants to merge 1 commit into
Open
arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
The cost arrays and the conditions list are returned from one call, and get_actual_value and CounterfactualValueEstimator both read column j as the cost of conditions[j]. Filling the columns in cc_dict iteration order made that alignment depend on how the caller happened to write the dict, so the same costs in a different key order charged each unit a different arm's cost. Build the columns from conditions_sorted instead, which also gives the array the documented width of len(conditions). Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
get_treatment_costsreturns the cost arrays and a sortedconditionslist from one call, andget_actual_valueandCounterfactualValueEstimatorboth read columnjas the cost ofconditions[j]. The columns were filled incc_dictiteration order, so that alignment only held when the dict was already written in the same order.Writing the same costs in a different order rotates them:
The first row is the right answer in both cases, since a control unit should pay nothing. The columns now follow
conditions_sorted, so the width islen(conditions)as documented rather thanlen(cc_dict), and an arm with no declared cost raisesKeyErrorinstead of returning a short array.One test added to
tests/test_value_optimization.py; it fails on master with the second row above. The existing test passes either way, since its dict is already control-first.