Skip to content

Commit

Permalink
FIX: do not use subsample index to get actual targets in UnivariatePr…
Browse files Browse the repository at this point in the history
…obabilitySimulator (#303)

* FIX: do not use subsample index to get actual targets in univ.prob.sim.

* TEST: update unit test for UnivariateProbabilitySimulator

* DOC: update release notes
  • Loading branch information
j-ittner authored Sep 22, 2021
1 parent 4dafa4d commit d50418c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ fit the underlying crossfit.
One example where this can be useful is to use only a recent period of a time series as
the baseline of a simulation.

1.2.1
~~~~~

- FIX: fix a bug in :class:`.UnivariateProbabilitySimulator` that was introduced in
FACET 1.2.0
- catch up with FACET 1.1.2


1.2.0
~~~~~

Expand Down
2 changes: 1 addition & 1 deletion src/facet/simulation/_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ def expected_output(self) -> float:
:return: observed frequency of the positive class
"""
actual_outputs = self.sample.target.loc[self.subsample]
actual_outputs = self.sample.target

return (actual_outputs == self._positive_class()).sum() / len(actual_outputs)

Expand Down
8 changes: 4 additions & 4 deletions test/test/facet/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,15 +505,15 @@ def test_univariate_probability_simulation(
)

index = pd.Index(
data=[5, 5.5, 6, 6.5, 7, 7.5], name=UnivariateUpliftSimulator.IDX_PARTITION
data=[5, 5.5, 6, 6.5, 7, 7.5, 8], name=UnivariateUpliftSimulator.IDX_PARTITION
)

assert simulation_result.baseline == approx(0.5)

assert_series_equal(
simulation_result.outputs_lower_bound(),
pd.Series(
[0.346255, 0.346255, 0.353697, 0.394167, 0.401895, 0.417372],
[0.346255, 0.346255, 0.353697, 0.394167, 0.401895, 0.417372, 0.417372],
name=UnivariateSimulationResult.COL_LOWER_BOUND,
index=index,
),
Expand All @@ -522,7 +522,7 @@ def test_univariate_probability_simulation(
assert_series_equal(
simulation_result.outputs_median(),
pd.Series(
[0.460432, 0.450516, 0.469412, 0.488569, 0.492651, 0.507788],
[0.460432, 0.450516, 0.469412, 0.488569, 0.492651, 0.507788, 0.507788],
name=UnivariateSimulationResult.COL_MEDIAN,
index=index,
),
Expand All @@ -531,7 +531,7 @@ def test_univariate_probability_simulation(
assert_series_equal(
simulation_result.outputs_upper_bound(),
pd.Series(
[0.582565, 0.562096, 0.570590, 0.580023, 0.599714, 0.602303],
[0.582565, 0.562096, 0.570590, 0.580023, 0.599714, 0.602303, 0.602303],
name=UnivariateSimulationResult.COL_UPPER_BOUND,
index=index,
),
Expand Down

0 comments on commit d50418c

Please sign in to comment.