Repository navigation
BUG: Correct dimension when data removed - #6888
Conversation
Correct exog dimension when data has been removed closes statsmodels#6887
|
|
||
| exog = np.asarray(exog) | ||
| if exog.ndim == 1 and (self.model.exog.ndim == 1 or | ||
| if exog.ndim == 1 and (self.model.exog is None or |
There was a problem hiding this comment.
this doesn't work if exog is None,
we need to check if exog had only 1 column
There was a problem hiding this comment.
The entire remove_data and still predict is fundamentally broken since this data isn't available when data has been removed. I think probably must raise in this case.
There was a problem hiding this comment.
we don't need model.exog for predict
remove_data was designed for predict without carrying around all the original data
There was a problem hiding this comment.
Except that it is needed to handle edge cases like this. Once it has been removed the correct decision cannot be reasoned here.
There was a problem hiding this comment.
As I mentioned on the mailing list, all we need to know is whether there is only 1 exog variable or more than 1.
It would be df_model except that doesn't count the const. In models without extra params, len(self.params) is sufficient
There was a problem hiding this comment.
Now using params since it needs to go through np.dot
Fix prediction by retaining required attributes Make private attribute private
| # GH6887 | ||
| endog = [i + np.random.normal(scale=0.1) for i in range(100)] | ||
| exog = [i for i in range(100)] | ||
| model = OLS(endog, exog, weights=[1 for _ in range(100)]).fit() |
Correct exog dimension when data has been removed
closes #6887
NumPy's guide.
Details
Notes:
needed for doc changes.
then show that it is fixed with the new code.
verify you changes are well formatted by running
flake8is installed. This command is also available on Windowsusing the Windows System for Linux once
flake8is installed in thelocal Linux environment. While passing this test is not required, it is good practice and it help
improve code quality in
statsmodels.