Skip to main content

Obtain visibility graphs from time series data.

Project description

ts2vg

Example of a Visibility Graph Visualized

The Python ts2vg package provides high-performance algorithm implementations to obtain visibility graphs from time series data.

The visibility graphs and some of their properties (e.g. degree distributions) are computed quickly and efficiently, even for time series with millions of observations, thanks to the use of NumPy and a custom C backend (with the help of Cython) developed for the visibility algorithms.

The (natural) visibility graphs are provided according to the mathematical definitions described in:

  • Lucas Lacasa et al., "From time series to complex networks: The visibility graph", 2008.

An efficient divide-and-conquer algorithm is used, as described in:

  • Xin Lan et al., "Fast transformation from time series to visibility graphs", 2015

Installation

The latest released ts2vg version is available at the Python Package Index and can be easily installed by running:

pip install ts2vg

For other advanced uses, to install ts2vg from source, Cython is required.

Python basic usage

Obtaining the edge list for the visibility graph of a time series:

from ts2vg import NaturalVisibilityGraph

ts = [0.87, 0.48, 0.36, 0.83, 0.87, 0.48, 0.36, 0.83]
edges = NaturalVisibilityGraph(ts).edgelist()

Obtaining the degree distribution for the visibility graph of a time series:

from ts2vg import NaturalVisibilityGraph

ts = [0.87, 0.48, 0.36, 0.83, 0.87, 0.48, 0.36, 0.83]
ks, pks = NaturalVisibilityGraph(ts).degree_distribution()

To obtain an igraph, NetworkX or SNAP graph object the following methods are provided:

  • as_igraph()
  • as_networkx()
  • as_snap()
from ts2vg import NaturalVisibilityGraph

ts = [0.87, 0.48, 0.36, 0.83, 0.87, 0.48, 0.36, 0.83]
vg = NaturalVisibilityGraph(ts).as_igraph()

Full documentation and information on all available features be found here.

Command Line Interface

ts2vg can also be used as a command line program directly from the console:

ts2vg ./timeseries.txt -o out.edg 

Use ts2vg -h to see additional help on the command line program use and features.

License

ts2vg is licensed under the terms of the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ts2vg-0.1.tar.gz (153.5 kB view hashes)

Uploaded Source

Built Distributions

ts2vg-0.1-cp38-cp38-win_amd64.whl (82.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

ts2vg-0.1-cp38-cp38-win32.whl (69.3 kB view hashes)

Uploaded CPython 3.8 Windows x86

ts2vg-0.1-cp36-cp36m-win_amd64.whl (81.1 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page