auto-infer locations for predict_dte/pte/ldte/lpte (#68)#114
Open
okiner-3 wants to merge 1 commit into
Open
Conversation
Make the locations argument optional in predict_dte, predict_pte, predict_ldte, and predict_lpte. When omitted, locations are generated automatically from the observed outcomes using np.linspace with a bin count derived from np.histogram_bin_edges(outcomes, bins='auto'). For the interval-based methods (PTE/LPTE), the left endpoint is shifted just below outcomes.min() so the smallest observation falls inside the first interval. The actual locations array used is stored on estimator.last_locations for plotting and downstream use.
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.
Summary
Closes #68. Make the
locationsargument optional inpredict_dte,predict_pte,predict_ldte, andpredict_lpte. When omitted, locations are generated automatically from the observed outcomes so users no longer need to writenp.linspace(Y.min(), Y.max(), N)themselves.Behavior
locations=None(default) → evenly-spaced locations spanning[Y.min(), Y.max()], with the bin count derived fromnp.histogram_bin_edges(outcomes, bins='auto')(combines Sturges and Freedman-Diaconis rules, scaling with data size and IQR).predict_pte/predict_lpte, the left endpoint is shifted just belowoutcomes.min()so that the smallest observation falls inside the first interval(loc[0], loc[1]].locations=ndarray(existing behavior) → used as-is. Fully backward compatible.estimator.last_locationsfor plotting / downstream use.Example
Test plan
_infer_default_locationsunit tests (tests/test_utils.py).SimpleDistributionEstimator.predict_dte/predict_pte(tests/test_simple_estimator.py).SimpleLocalDistributionEstimator.predict_ldte/predict_lpte(tests/test_local_estimators.py).