facebookresearch / Kats

Kats, a kit to analyze time series data, a lightweight, easy-to-use, generalizable, and extendable framework to perform time series analysis, from understanding the key statistics and characteristics, detecting change points and anomalies, to forecasting future trends.
MIT License
4.88k stars 534 forks source link

Calculating timeseries features using get_meta_data() with different periodicity. #244

Closed robertcurler closed 2 years ago

robertcurler commented 2 years ago

Hi there,

I am trying to use the Kats.metalearner package to generate a classifier on monthly data. However the standard periodicity is set to 7 in the feature generation call: TsFeatures( window_size: int = 20, spectral_freq: int = 1, stl_period: int = 7,...

So basicly I am initializing a GetMetaData class as follows:

GetMetaData(data=series, all_models=all_models,
            all_params=all_params,
            error_method='rmse',
            min_length=24)#,
            #"stl_period": 12)

And then I follow up with a get_meta_data() call like so: metadata_dict[timeseriesID] = metadata_dict_class[timeseriesID].get_meta_data() Which then runs TsFeatures().transform(self.data) in its first line.

In my limited knowledge of OOP, I tried to funnel the alternative stl_period in the GetMetaData init. call. My approach didn't work.

Is there a way of correctly funneling this alternative setting, or should i skip the get_meta_data() and adjust the settings of the calls present in get_meta_data() manually?

Regards, Robert

neelabalan commented 2 years ago

I think you can call the tune_executor and TsFeatures().transform (with custom args) separately and merge the dictionaries to get the metadata.

peiyizhang commented 2 years ago

Hi Robert, thanks so much for your questions.

We just added this function into GetMetaData module. Now if you would like to apply that, you could try:

GMD = GetMetaData(data=TSdata)
_ = GMD.get_meta_data(stl_period=your_alternative_number)

And this will run TsFeatures(stl_period=your_alternative_number).transform(self.data) in its first line. You could also use alternative window_size, spectral_freq, nbins, lag_size, etc.

Note that you have to install Kats from source again to be able to use this change.

Please let us know if you have any further questions!

iamxiaodong commented 2 years ago

issue resolved, close this issue

robertcurler commented 2 years ago

Hey all,

I finally got around to trying it myself. Works as expected ;)

Thanks a bunch!