Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import CausalImpact because of NameError: #1

Closed
BernFox opened this issue Dec 7, 2016 · 8 comments
Closed

Cannot import CausalImpact because of NameError: #1

BernFox opened this issue Dec 7, 2016 · 8 comments

Comments

@BernFox
Copy link

BernFox commented Dec 7, 2016

When I import causalimpact, as such

import causalimpact

I get this error

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-707f1b214cc6> in <module>()
----> 1 import causalimpact

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/causalimpact-0.1-py2.7.egg/causalimpact/__init__.py in <module>()
      7 """
      8 
----> 9 from causalimpact.analysis import CausalImpact  # noqa
     10 from causalimpact.tests.test import run as test  # noqa

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/causalimpact-0.1-py2.7.egg/causalimpact/analysis.py in <module>()
      6 from causalimpact.misc import standardize_all_variables
      7 from causalimpact.model import construct_model
----> 8 from causalimpact.inferences import compile_posterior_inferences
      9 
     10 class CausalImpact(object):

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/causalimpact-0.1-py2.7.egg/causalimpact/inferences.py in <module>()
      1 from causalimpact.misc import unstandardize
      2 def compile_posterior_inferences(model, data_post, alpha=0.05,
----> 3                                  orig_std_params=identity):
      4 
      5     # Compute point predictions of counterfactual (in standardized space)

NameError: name 'identity' is not defined

I looked at the source code and found that identity is a default arg for compile_posterior_inferences, but identity doesn't exist. I looked elsewhere in the code to see if identity is referenced elsewhere to see if I could fix it myself, and found that theres this: orig_std_params = np.identity on line 243 of analysis.py, but np.identity is a function that returns the identity matrix. It it assigned to the variable orig_std_params without actually giving np.identity an argument. The orig_std_params variable is then reassigned to some other value. So I couldn't make sense of how to fix the code. Also, compile_na_inferences in inferences.py doesn't do anything, seems wrong because the function is used elsewhere in the package.

So I don't know how to use the package as such....

@jamalsenouci
Copy link
Owner

yeah, i only got halfway through this. There's still a lot of work to make it useable but I haven't had time to work on it for a while.

@oostopitre
Copy link

Is there a known workaround to getting this to work so that we can play with the existing functionality of the library?

@jamalsenouci
Copy link
Owner

jamalsenouci commented Dec 18, 2016 via email

@haydenliu
Copy link

I got the same error, and tried to fix it, but gave up :)

@pabloazurduy
Copy link

Hi @jamalsenouci ¿Is this library still under development ? or it's an abandoned project? thanks! :)

@kristomi
Copy link

kristomi commented May 24, 2017

@haydenliu and @jamalsenouci: See this library https://github.com/tcassou/causal_impact. Maybe it has come further.

@jamalsenouci
Copy link
Owner

I picked up development on this, there is something that works at the moment but only works with maximum likelihood estimation and still needs a lot of testing

@BernFox
Copy link
Author

BernFox commented Jul 18, 2017

Oh cool! Thanks for following up. I did however build my own solution to this kind of problem. Check it out:
https://medium.com/refinery29-pe/seo-a-b-testing-with-predictive-analysis-68c399d231b5

jamalsenouci pushed a commit that referenced this issue Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants