You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TTRA is a lightweight algorithm reducing a time-series with a time omission. It has been described in the Master's Thesis.
Example of real-time usage
Installation
pip install ttra
Usage
importpandasaspdimportmatplotlib.pyplotaspltfromttraimportTTRA# define minimal percentage change that should be detected by TTRAPCT_CHANGE: float=0.01# let's take the inflation in Poland as an examplesource: str="https://stat.gov.pl/download/gfx/portalinformacyjny/pl/defaultstronaopisowa/4741/1/1/miesieczne_wskazniki_cen_towarow_i_uslug_konsumpcyjnych_od_1982_roku_13-05-2022.csv"# download and process datainflation=pd.read_csv(source,encoding='ISO-8859-2',sep=';').sort_values(['Rok','Miesišc'])
inflation=inflation[inflation['Sposób prezentacji'] =='Analogiczny miesišc poprzedniego roku = 100']
inflation=inflation['Warto�ć'].dropna().map(lambdax: x.replace(',','.')).astype(float)
inflation=inflation.iloc[-12*25:].reset_index(drop=True) # last 25 years only to not obscure the newest data# initiate TTRA and reduce data with a given PCT_CHANGEtr=TTRA(inflation)
reduced=tr.reduce(PCT_CHANGE)
# plot data, reduced data and an assumption of the current extremumfig, ax=plt.subplots()
inflation.plot(ax=ax)
reduced.plot(ax=ax)
plt.scatter(tr.a.Index, tr.a.x, s=150 , color='black')
Output
About
Implementation of the algorithm created and analysed within Master's Thesis.