REF: Results.predict convert to array and adjust shape #1254

Merged
merged 1 commit into from Dec 19, 2013

Projects

None yet

2 participants

@josef-pkt
Member

Results.predict
convert to ndarray, and check and adjust shape, with unit_tests

closes #1032
supersedes #1178

I tried to let pandas through, but it doesn't help. np.dot for example returns an ndarray.
I left the commented out code for testing DataFrame in the generic tests, but it needs special handling on before return.
I don't know if we have any wrapper code for predict. I didn't see any.

Some comments on the requirements

  • CountModels require 2d even if it's only a single prediction because of exog.shape[1]
  • single regressor (OLS example) needs reshape to column_vector as in AR(MA)
  • I'm not sure we always have model.exog as 2d, so I check also for 1d model.exog
  • I didn't find self.data.k_exog or self.model.data.k_exog, so I did a model.exog.shape check directly
@josef-pkt
Member

@jseabold Do you know if there is any wrapper for predict, or any examples were predict returns a DataFrame with correct index?

This PR converts every exog to ndarray. subclasses need to handle extra arrays, like exposure in count models.

@coveralls

Coverage Status

Coverage remained the same when pulling ada08b9 on josef-pkt:fix_predict_1032 into 01fd4a2 on statsmodels:master.

@josef-pkt
Member

ready to merge IMO, unless there is a problem with DataFrames.

@josef-pkt josef-pkt merged commit 0b5ed74 into statsmodels:master Dec 19, 2013

1 check passed

default The Travis CI build passed
Details
@josef-pkt josef-pkt deleted the josef-pkt:fix_predict_1032 branch Dec 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment