WillianFuks / tfcausalimpact

Python Causal Impact Implementation Based on Google's R Package. Built using TensorFlow Probability.
Apache License 2.0
600 stars 72 forks source link

AttributeError: 'CausalImpact' object has no attribute 'inferences' #39

Closed AInhoa84 closed 2 years ago

AInhoa84 commented 2 years ago

Hello!

I've been trying to use the library as it's exactly what I would need, but I keep receiving the error "AttributeError: 'CausalImpact' object has no attribute 'inferences'" everytime.

This is what my Jupyter Notebook looks like:

Capture1

And these are the errors:

Capture2

I am also attaching the csv example file FYI:

example_Github.csv

Thanking you in advance for your support and wishing you an excellent New Year!

Regards,

Ainhoa

WillianFuks commented 2 years ago

Hi Ainhoa,

Happy New Year to you as well :)

As for the issue you are seeing, I suspect that you are not actually using this package (tfcausalimpact), the error message seems to reference other implementations also available for Python.

If you want to use this current repository, you can just run pip install tfcausalimpact and then you'll have access to causal impact as implemented on top of Tensorflow Probability. If you want to keep using your current implementation of causal impact then you'll probably have to figure out which repository it refers to and ask them for help.

Let me know if this helps you.

Best,

Will

wobiero commented 2 years ago

Happy New Year Will,

I also seem to be having the same issue. I recently updated pandas and since then tfcausalimpact has been broken. Exactly the same errors as Alnhoa84. I have uninstalled and reinstalled the package and removed all other existing packages with similar names, and the error persists.

Cheers,

W.

WillianFuks commented 2 years ago

Hi @wobiero ,

What is the output if you run this command?:

pip freeze | grep causalimpact

If you have the same issue than @AInhoa84 then it would indicate other package is being used instead of tfcausalimpact, the output of that command will confirm what's going on.

Best,

Will

wobiero commented 2 years ago

Hi @wobiero ,

What is the output if you run this command?:

pip freeze | grep causalimpact

If you have the same issue than @AInhoa84 then it would indicate other package is being used instead of tfcausalimpact, the output of that command will confirm what's going on.

Best,

Will

Hi Will,

You were right. I had some conflicts that I resolved. Working perfectly. Thanks for the great job.

Best.

W

AInhoa84 commented 2 years ago

Hi @WillianFuks,

Thanks for your answer.

I have just pip installed tfcausalimpact and ran the command you mentioned:

Capture

And I still get the same errors. Should I uninstall the 1st causalimpact package? FYI, I am using your notebook https://github.com/WillianFuks/tfcausalimpact/blob/master/notebooks/getting_started.ipynb as a step-by-step guide.

Apologies as I am not an advanced Python user, but still really like this package and want to use it!

Regards,

Ainhoa

WillianFuks commented 2 years ago

Hi Ainhoa,

I suspect that indeed if you remove the first package then the notebook will process just fine. Both packages installed seems to cause conflicts when importing them.

wobiero commented 2 years ago

Hi Ainhoa,

I suspect that indeed if you remove the first package then the notebook will process just fine. Both packages installed seems to cause conflicts when importing them.

Hi Alnhoa,

For me the issue was that I had another causalimpact library installed. It has a similar import statement to tfcausalimpact i.e., "from causalimpact import CausalImpact".

When I ran the pip uninstall command, it wasn't getting removed. I had to physically delete the library, upgrade tensorflow and then reinstall tfcausalimpact.

Also try and install tfcausalimpact in your python root directory. That is, "python -m pip install tfcausalimpact" rather than "pip install tfcausalimpact".

Hope this helps.

W

AInhoa84 commented 2 years ago

Hello,

Thanks both @WillianFuks and @wobiero it's working now! :)

Regards,

Ainhoa