firmai / atspy

AtsPy: Automated Time Series Models in Python (by @firmai)
https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3580631
510 stars 89 forks source link

UnboundLocalError: local variable 'periodocity' referenced before assignment #14

Open sr-ubuntu opened 4 years ago

sr-ubuntu commented 4 years ago

Hi,

A very interesting project, really appreciate it. Got the below error while giving it a try, please help

<class 'pandas.core.frame.DataFrame'> The data has been successfully parsed by infering a frequency, and establishing a 'Date' index and 'Target' column. 140 An insample split of training size 140 and testing size 47 has been constructed

UnboundLocalError Traceback (most recent call last)

in ----> 1 forecast_in, performance = am.forecast_insample(); forecast_in ~/anaconda3/envs/srtest/lib/python3.6/site-packages/atspy/__init__.py in forecast_insample(self) 845 846 def forecast_insample(self): --> 847 models_dict, freq, test = self.train_insample() 848 forecast_len = test.shape[0] 849 forecast_dict = forecast_models(models_dict, forecast_len, freq,test, in_sample=True, GPU=self.GPU) ~/anaconda3/envs/srtest/lib/python3.6/site-packages/atspy/__init__.py in train_insample(self) 834 train, test = train_test_split(dataframe, train_proportion=0.75) 835 forecast_len = len(test) --> 836 models, seasonal = train_models(train, models= self.model_list,forecast_len= forecast_len,full_df=dataframe,seasonality=self.season,in_sample=True,freq=freq, GPU=self.GPU ) 837 self.seasonality = seasonal 838 ~/anaconda3/envs/srtest/lib/python3.6/site-packages/atspy/__init__.py in train_models(train, models, forecast_len, full_df, seasonality, in_sample, freq, GPU) 317 seasons = select_seasonality(train, seasonality) 318 --> 319 periods = select_seasonality(train, 'periodocity') 320 321 models_dict = {} ~/anaconda3/envs/srtest/lib/python3.6/site-packages/atspy/__init__.py in select_seasonality(train, season) 149 def select_seasonality(train, season): 150 if season == "periodocity": --> 151 seasonality = infer_periodocity(train) 152 elif season== "infer_from_data": 153 seasonality = infer_seasonality(train) ~/anaconda3/envs/srtest/lib/python3.6/site-packages/atspy/__init__.py in infer_periodocity(train) 145 periodocity = 1000 146 --> 147 return periodocity 148 149 def select_seasonality(train, season): UnboundLocalError: local variable 'periodocity' referenced before assignment
stefanosh commented 4 years ago

I have experienced the same error when using sub-daily time series data such as hourly data etc. For example data with frequencies of the following: "3H", "5T" (minutes).

jtfields commented 4 years ago

I didn’t see this issue and posted a new one this morning. I’m trying to use annual data (2007, 2008, etc) and I get the same error. I wonder if there is a way to specify the frequency and not have AtsPy infer it?

rahul4tripathi2 commented 4 years ago

Solution - https://github.com/firmai/atspy/issues/16