Skip to content

Implementation of the algorithm created and analysed within Master's Thesis.

License

Notifications You must be signed in to change notification settings

tomWitkowski/Time-proof-Time-series-Reduction-Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Time-proof Time-series Reduction Algorithm

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

animation

Installation

pip install ttra

Usage

import pandas as pd
import matplotlib.pyplot as plt
from ttra import TTRA

# define minimal percentage change that should be detected by TTRA
PCT_CHANGE: float = 0.01
    
# let's take the inflation in Poland as an example
source: 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 data
inflation = 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(lambda x: 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_CHANGE
tr = TTRA(inflation)
reduced = tr.reduce(PCT_CHANGE)

# plot data, reduced data and an assumption of the current extremum
fig, ax = plt.subplots()
inflation.plot(ax=ax)
reduced.plot(ax=ax)
plt.scatter(tr.a.Index, tr.a.x, s= 150 , color='black')

Output

image

About

Implementation of the algorithm created and analysed within Master's Thesis.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages