Repository navigation
TST: Follow up on #10590, test MNLogit and the one-row case of predict - #10594
Merged
Merged
Conversation
Add MNLogit, which has two sets of parameters and a DataFrame result, to the tests of predict with a Series, and a test that a Series is still one observation when the model has two exog columns. Say what the tests of the formula models after remove_data protect. Add the :pr: role and the other affected models to the release note. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.
NumPy's guide.
Follow up to #10590.
Tests (
statsmodels/base/tests/test_predict.py)test_predict_series_mnlogit:MNLogitwith one exog column hasparams.size == 2and a DataFrame result with one column per category. The expected probabilities are computed from the fitted parameters with a softmax, and the index of the Series is checked for one and three observations. Both cases fail with the old conditionparams.size == 1and pass now.test_predict_series_is_one_row_with_two_exog: a Series is still one observation for a model with two exog columns, which is the other side of the condition onexog.shape[1].test_formula_series_after_remove_datasays that these cases also pass without the change of the condition and protect the guard for a model withoutexog.Release note
version0.15.1.rsthas the:pr:role, and names the other models that were affected (GeneralizedPoisson,ZeroInflatedPoisson,BetaModel,MNLogit).Not changed
exog.shape[1] == 1is written in three places (base/model.pytwice andbase/_prediction_inference.py); a helper is not worth a change here.[exog.index.name], and a non-formula Series afterremove_data()raises anAttributeError.Verified:
test_predict.py22 passed (Python 3.13, NumPy 2.5.4, SciPy 1.18.1);ruff checkclean.AI Disclosure
Contributions must comply with the statsmodels AI Policy.
Tick exactly one of the following. If AI tools were used, replace the
<...>placeholders in the second option with the tool name(s) and how the tool's output was
used.
Tool(s): Claude Code (Claude Sonnet 5.5).
Used for: reviewing the merged PR across 13 model types, and drafting the tests and release note.
I have personally read, understood, and can explain every line of this diff, and
have verified the statistical/numerical correctness of the change.
🤖 Generated with Claude Code