Skip to content

BUG: regression, allow remove_data to remove wendog, wexog, wresid - #7595

Merged
josef-pkt merged 2 commits into
statsmodels:mainfrom
josef-pkt:fix_regression_remove_data
Jul 20, 2021
Merged

josef-pkt merged 2 commits into
statsmodels:mainfrom
josef-pkt:fix_regression_remove_data

Conversation

@josef-pkt

@josef-pkt josef-pkt commented Jul 20, 2021 •

Copy link
Copy Markdown
Member

This partially reverts changes in OLS for remove_data in #6888, now wendog, wexog and wresid are removed again
reported in #7494 (comment)

unit test changed to call results scale before remove_data, so that get_prediction works #6887

This does not revert changes other than wendog, wexog and wresid
e.g. RLM sresid is not removed after 6888, which I guess can also be reverted.
correction, I read that part too fast, sresid is in cache list and is removed.
(In unit test case, RLM size shrinks to less than 3% of original size)

open question: Why did unit tests not catch that remove_data didn't remove the wxxx arrays?

@josef-pkt

Copy link
Copy Markdown
Member Author

unit test for pickle size have been watered down, so they don't fail anymore even if some arrays are not removed

7d1f096#diff-9d0080706eec612b4e32badb782c7495e9444606bb967b66f9823e30d06caaf6L82
dropped the model specific size, and replace it by "some reduction"

https://github.com/statsmodels/statsmodels/pull/6311/files
reduce nobs, so arrays are not very large, and keeping some in doesn't make enough difference

@josef-pkt

Copy link
Copy Markdown
Member Author

If I use a reduction by a factor of 10 compared to original size, then unit test for wls fails if wendog is not removed

        msg = 'pickle length not %d < %d' % (nbytes, orig_nbytes)
>       assert nbytes < orig_nbytes / 10, msg
E       AssertionError: pickle length not 18065 < 130413
E       assert 18065 < (130413 / 10)

..\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\base\tes
ts\test_shrink_pickle.py:80: AssertionError

However, factor 10 does not work for formulas because the reduction in pickle size is not very large (we need to keep original data)
To separate the threshold for fomulas, was the original reason to add a test class attribute
b5fe60b

@josef-pkt

josef-pkt commented Jul 20, 2021 •

Copy link
Copy Markdown
Member Author

using 0.1, and 0.5 for required reduction factor, then if I exclude endog from remove data, I get the following test failures

so this looks fine as threshold, but it might not be binding in all cases (I didn't check all test cases)
update playing with this a bit 0.1 and 0.5 cannot be reduced by much as general threshold without making higher limit for a few test cases. (0.1 could be reduced to 0.08 but not worth it I guess)

FAILED ..\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\b
ase\tests\test_shrink_pickle.py::TestRemoveDataPickleOLS::test_remove_data_pickl
e
FAILED ..\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\b
ase\tests\test_shrink_pickle.py::TestRemoveDataPickleWLS::test_remove_data_pickl
e
FAILED ..\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\b
ase\tests\test_shrink_pickle.py::TestRemoveDataPicklePoisson::test_remove_data_p
ickle
FAILED ..\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\b
ase\tests\test_shrink_pickle.py::TestRemoveDataPickleLogit::test_remove_data_pic
kle
FAILED ..\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\b
ase\tests\test_shrink_pickle.py::TestRemoveDataPickleRLM::test_remove_data_pickl
e
FAILED ..\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\b
ase\tests\test_shrink_pickle.py::TestRemoveDataPickleGLM::test_remove_data_pickl
e
FAILED ..\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\b
ase\tests\test_shrink_pickle.py::TestPickleFormula::test_remove_data_pickle
FAILED ..\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\b
ase\tests\test_shrink_pickle.py::TestPickleFormula2::test_remove_data_pickle
FAILED ..\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\b
ase\tests\test_shrink_pickle.py::TestPickleFormula3::test_remove_data_pickle
FAILED ..\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\b
ase\tests\test_shrink_pickle.py::TestPickleFormula4::test_remove_data_pickle
FAILED ..\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\b
ase\tests\test_shrink_pickle.py::TestPickleFormula5::test_remove_data_pickle
FAILED ..\eclipse_ws\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\b
ase\tests\test_shrink_pickle.py::TestRemoveDataPicklePoissonRegularized::test_re
move_data_pickle

pred = model.get_prediction([1])
one_d = pred.predicted_mean
assert_allclose(scalar, one_d)
# smoke test for inferenctial part

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

speling

@josef-pkt

Copy link
Copy Markdown
Member Author

all green, merging

@josef-pkt
josef-pkt merged commit ea1d8db into statsmodels:main Jul 20, 2021
@josef-pkt
josef-pkt deleted the fix_regression_remove_data branch October 19, 2022 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant