RainBoltz / Series2GAF

simple time series encoding package
38 stars 12 forks source link

About

Series2GAF

simple time series encoding package, focused on financial tasks.

this is an simple example:

import numpy as np
from series2gaf import GenerateGAF

# create a random sequence with 200 numbers
# all numbers are in the range of 50.0 to 150.0
random_series = np.random.uniform(low=50.0, high=150.0, size=(200,))

# set parameters
timeSeries = list(random_series)
windowSize = 50
rollingLength = 10
fileName = 'demo_%02d_%02d'%(windowSize, rollingLength)

# generate GAF pickle file (output by Numpy.dump)
GenerateGAF(all_ts = timeSeries,
            window_size = windowSize,
            rolling_length = rollingLength,
            fname = fileName)

now we get a file named _demo_50_10_gaf.pkl_ in current directory. inside the pickle file, you got a grammian angular field with shape (15, 50, 50).

Thats It!

if we want to preview the image results, just add these to the code:

from series2gaf import PlotHeatmap

gaf = np.load('%s_gaf.pkl'%fileName)
PlotHeatmap(gaf)

we can now find GAF heapmap images in a new child directory _/output_img_!

Functions

def GenerateGAF(all_ts, window_size, rolling_length, fname,
                normalize_window_scaling=1.0, method='summation', scale='[0,1]'):
  ...

def PlotHeatmap(all_img, save_dir='output_img'):
  ...

Parameters


development environment