Git Product home page Git Product logo

series2gaf's Introduction

About

  • Series2GAF can be used to transform time series into Gramian Angular Field. GAF DEMO
  • There are many useful utility features for financial research in Series2GAF, and will be mentioned in the following sections.

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).

  • shape[0] refers to data amount : floor((len(timeSeries)-(normalize_window_scaling-1)*windowSize)/windowSize)
  • shape[1] refers to image width : windowSize
  • shape[2] refers to image height : windowSize

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

  • all_ts: list
        the time series we want to transform.

  • window_size: int
        the sliding window size for transforming sequences into GAF images

  • rolling_length: int
        also known as "stride value" for the sliding window

  • fname: str
        output file name, the output pickle file will be named as "[fname]_gaf.pkl"

  • normalize_window_scaling: float, optional
        default: 1.0
        normalize the values in the windows, but considering a ratio of previous values

  • method: str, optional
        default: 'summation'
        'summation' is for GASF ( calculate cos(x1+x2) )
        'difference' if for GADF ( calculate sin(x1-x2) )

  • scale: str, optoinal
        default: '[0,1]'
        '[0,1]' means normalize the sequence in the range of 0 and 1
        '[-1,1]' means normalize the sequence in the range of -1 and 1

  • all_img: numpy.array
        input GAF multi-dimension array

  • save_dir: str, optional
        default: 'output_img'
        directory for output images


series2gaf's People

Contributors

rainboltz avatar bigmoumou avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.