WillianFuks / tfcausalimpact

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

value erro r #87

Closed aazz7777 closed 3 months ago

aazz7777 commented 3 months ago

ValueError: Pandas DataFrame or Series has a DatetimeIndex with no set frequency, but STS requires regularly spaced observations. Consider using tfp.sts.regularize_series to infer a frequency and build a regularly spaced series (by marking unobserved steps as missing observations).

I test with this code

import pandas as pd from causalimpact import CausalImpact

data = pd.read_csv('https://raw.githubusercontent.com/WillianFuks/tfcausalimpact/master/tests/fixtures/comparison_data.csv', index_col=['DATE']) pre_period = ['2019-04-16', '2019-07-14'] post_period = ['2019-7-15', '2019-08-01'] ci = CausalImpact(data, pre_period, post_period, model_args={'fit_method': 'hmc'})

WillianFuks commented 3 months ago

Hi @aazz7777 ,

I suspect that you are using an old version of tfci. What is the output of running pip show tfcausalimpact?

Meanwhile you could try running pip install -U tfcausalimpact && pip install tensorflow-probability[tf] to see if it works.

aazz7777 commented 3 months ago

I found the package that install was really old version from other library tfcausalimpact==0.0.5 . once changed to Version: 0.0.14 it worked! thank you!