-
Notifications
You must be signed in to change notification settings - Fork 73
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
have an error when using customized model #76
Comments
Hi @justdoit456258 , Apparently you are using the wrong package. Please run |
@WillianFuks AssertionError Traceback (most recent call last) ~\second_anacode_setup\envs\py37\lib\site-packages\causalimpact\main.py in init(self, data, pre_period, post_period, model, model_args, alpha) ~\second_anacode_setup\envs\py37\lib\site-packages\causalimpact\data.py in process_input_data(data, pre_period, post_period, model, model_args, alpha) ~\second_anacode_setup\envs\py37\lib\site-packages\causalimpact\model.py in check_input_model(model, pre_data, post_data) ~\second_anacode_setup\envs\py37\lib\site-packages\causalimpact\model.py in _check_component(component) AssertionError: |
Hi @justdoit456258 , As it seems your input weight matrix should be casted to type |
Thank you for your reply! I found that this code is causing the AssertionError: But now,I have new question that I need to consult with you. Even if the P-value is lower then 0.05,the prediction curve appears to have clearly not learned historical trends. Sincerely looking forward to your new reply! |
Hi @justdoit456258 , There are many factors that should be weighted in that may explain the observed. Some ideas to investigate:
This tends to be an exploration and you can use the results and inferred data to guide you on what is working or not. You could also use some error metrics such as MAE (if it's appropriate to your use case) to guide you on which model is working best. |
Hi @WillianFuks , I have tried to add seasonal components and covariates of festival tags to train my model. But there is still no improvement. The attachment file is my code.Could you you run it to see where it can be optimized? |
Hi @WillianFuks ,
Now I was trying to run example with customized model, but it doen't work
when running ’ci = CausalImpact(data1, pre_period, post_period, model= model1,model_args={'standardize': True})‘,
I encountered the error: ValueError: Input model must be of type UnobservedComponents.
can you help me ? Thank you !
example:
import pandas_datareader as pdr
import datetime
from causalimpact import CausalImpact
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from causalimpact.misc import standardize
data = pd.read_csv('volks_data.csv')
data.plot()
data1 = data[['Date','VolksWagen']]
pre_period = ['2011-01-02', '2015-09-13']
post_period = ['2015-09-20', '2017-03-19']
reg_data = tfp.sts.regularize_series(data1)
normed_data = standardize(reg_data.astype(np.float32))[0]
obs_data = normed_data.loc[pre_period[0]: pre_period[1]].iloc[:, 0]
design_matrix = pd.concat([normed_data.loc[pre_period[0]: pre_period[1]], normed_data.loc[post_period[0]: post_period[1]]]
).astype(np.float32).iloc[:, 1:]
linear_level = tfp.sts.LocalLinearTrend(observed_time_series=obs_data)
linear_reg = tfp.sts.LinearRegression(design_matrix=design_matrix)
model1 = tfp.sts.Sum([linear_level, linear_reg], observed_time_series=obs_data)
ci = CausalImpact(data1, pre_period, post_period, model= model1,model_args={'standardize': True})
The text was updated successfully, but these errors were encountered: