Package: tsfeatures
tsfeaturesCalculates various features from time series data. Python implementation of the R packagetsfeatures.InstallationYou can install thereleasedversion oftsfeaturesfrom thePython package indexwith:pipinstalltsfeaturesUsageThetsfeaturesmain function calculates by default the features used by Montero-Manso, Talagala, Hyndman and Athanasopoulos intheir implementation of the FFORMA model.fromtsfeaturesimporttsfeaturesThis function receives a panel pandas df with columnsunique_id,ds,yand optionally the frequency of the data.tsfeatures(panel,freq=7)By default (freq=None) the function will try to infer the frequency of each time series (usinginfer_freqfrompandason thedscolumn) and assign a seasonal period according to the built-in dictionaryFREQS:FREQS={'H':24,'D':1,'M':12,'Q':4,'W':1,'Y':1}You can use your own dictionary using thedict_freqsargument:tsfeatures(panel,dict_freqs={'D':7,'W':52})List of available featuresFeaturesacf_featuresheterogeneityseries_lengtharch_statholt_parameterssparsitycount_entropyhurststabilitycrossing_pointshw_parametersstl_featuresentropyintervalsunitroot_kpssflat_spotslumpinessunitroot_ppfrequencynonlinearityguerreropacf_featuresSee the docs for a description of the features. To use a particular feature included in the package you need to import it:fromtsfeaturesimportacf_featurestsfeatures(panel,freq=7,features=[acf_features])You can also define your own function and use it together with the included features:defnumber_zeros(x,freq):number=(x==0).sum()return{'number_zeros':number}tsfeatures(panel,freq=7,features=[acf_features,number_zeros])tsfeaturescan handle functions that receives a numpy arrayxand a frequencyfreq(this parameter is needed even if you don't use it) and returns a dictionary with the feature name as a key and its value.R implementationYou can use this package to calltsfeaturesfrom R inside python (you need to have installed R, the packagesforecastandtsfeatures; also the python packagerpy2):fromtsfeatures.tsfeatures_rimporttsfeatures_rtsfeatures_r(panel,freq=7,features=["acf_features"])Observe that this function receives a list of strings instead of a list of functions.Comparison with the R implementation (sum of absolute differences)Non-seasonal data (100 Daily M4 time series)featuredifffeaturedifffeaturedifffeaturediffe_acf100e_acf10diff2_acf10alpha3.2seasonal_period0spike0diff1_acf100arch_acf3.3nperiods0curvature0x_acf10beta4.04linearity0crossing_points0nonlinearity0garch_r24.74hw_gamma0lumpiness0diff2x_pacf50hurst5.45hw_beta0diff1x_pacf50unitroot_kpss0garch_acf5.53hw_alpha0diff1_acf100x_pacf50entropy11.65trend0arch_lm0x_acf100flat_spots0diff1_acf10unitroot_pp0series_length0stability0arch_r21.37To replicate this results use:python -m tsfeatures.compare_with_r --results_directory /some/path--dataset_name Daily --num_obs 100Sesonal data (100 Hourly M4 time series)featuredifffeaturedifffeaturedifffeaturediffseries_length0seas_acf10trend2.28hurst26.02flat_spots0x_acf10arch_r22.29hw_beta32.39nperiods0unitroot_kpss0alpha2.52trough35crossing_points0nonlinearity0beta3.67peak69seasonal_period0diff1_acf100linearity3.97lumpiness0x_acf100curvature4.8stability0seas_pacf0e_acf107.05arch_lm0unitroot_pp0garch_r27.32diff2_acf10spike0hw_gamma7.32diff2_acf100seasonal_strength0.79hw_alpha7.47diff1_acf10e_acf11.67garch_acf7.53diff2x_pacf50arch_acf2.18entropy9.45To replicate this results use:python -m tsfeatures.compare_with_r --results_directory /some/path \--dataset_name Hourly --num_obs 100AuthorsFederico Garza-FedericoGarzaKin Gutierrez-kdgutierCristian Challu-cristianchalluJose Moralez-jose-moralezRicardo Olivares-rolivaresarMax Mergenthaler-mergenthaler