Vector visibility graph generation from multivariate time series.
Project description
Vector Visibility Graph
This repository contains the Numba JIT-compiled implementation of the Vector Visibility Graphs (VVGs), which are a generalization of the Visibility Graphs (VGs) for multivariate time series. For a single time series, ts2vg (GitHub, PyPI) provides a detailed and thorough construction of VGs with a Cython-based approach for performance. However, this implementation is not directly applicable to multivariate time series. Therefore, in this package, we implement the construction of VVGs for multivariate time series using a Numba-based approach for performance.
This package is developed for the work titled "VISPool: Enhancing Transformer Encoders with Vector Visibility Graph Neural Networks" by Tuna Alikaşifoğlu, Arda Can Aras, and Aykut Koç, which is accepted to Findings of ACL 2024. You can also see this package in action in the VISPool repository: koc-lab/vispool. Please cite the following paper if you use this package (or use alikasifoglu-etal-2024-vispool tag from ACL Anthology BibTeX):
@inproceedings{alikasifoglu-etal-2024-vispool,
title = {{VISP}ool: Enhancing Transformer Encoders with Vector Visibility Graph Neural Networks},
author = {Alika{\c{s}}ifo{\u{g}}lu, Tuna and Aras, Arda and Koc, Aykut},
editor = {Ku, Lun-Wei and Martins, Andre and Srikumar, Vivek},
booktitle = {Findings of the Association for Computational Linguistics: ACL 2024},
month = aug,
year = {2024},
address = {Bangkok, Thailand},
publisher = {Association for Computational Linguistics},
url = {https://aclanthology.org/2024.findings-acl.149/},
doi = {10.18653/v1/2024.findings-acl.149},
pages = {2547--2556}
}
Installation
You can install the package directly from PYPI using pip as follows:
pip install vector-vis-graph
or directly from Conda
conda install -c conda-forge vector-vis-graph
Usage
Given a multivariate time series, the vector_vis_graph package can be used to construct a vector visibility graph (VVG). The package provides two functions natural_vvg() and horizontal_vvg() with the same input types for constructing Natural and Horizontal VVGs. They take a multivariate time series where the rows correspond to the time steps and the columns correspond to the vector components such that for a multivariate time series, mts, mts[i] is the vector at time step i. The functions also take the following optional arguments:
timeline: The timeline of the multivariate time series. If not provided, the timeline is assumed to be[0, 1, 2, ...].weight_method: The method used to calculate the weight of the edges. The default isWeightMethod.UNWEIGHTED. There are a few other options available in theWeightMethodenum.penetrable_limit: The penetrable limit of the "visibility" of the vectors. For two vectors at different time steps to be visible to each other, the vectors at in-between time steps must satisfy certain conditions. The penetrable limit is the number of in-between time steps that can violate the conditions. The default is0.directed: Whether the graph is directed or undirected. The visibility of the vectors is calculated in aleft-to-rightdirected manner. Ifdirected, the calculated graph adjacency matrix is returned, else its sum with its transpose is returned. The default isFalse, so undirected.
import numpy as np
from vector_vis_graph import WeightMethod, horizontal_vvg, natural_vvg
# Multivariate Time Series
TIME_LENGTH = 100
VEC_SIZE = 64
multivariate_ts = np.random.rand(TIME_LENGTH, VEC_SIZE)
# Natural Vector Visibility Graph with Default Parameters
# Timeline: [0, 1, 2, ...]
# Weight Method: Unweighted
# Penetrable Limit: 0
# Undirected Graph
nvvg_adj = natural_vvg(multivariate_ts)
# Horizontal Vector Visibility Graph with All Custom Parameters
# Timeline: [0, 2, 4, ...]
# Weight Method: Cosine Similarity
# Penetrable Limit: 2
# Directed Graph
hvvg_adj = horizontal_vvg(
multivariate_ts,
timeline=np.arange(0, 2 * TIME_LENGTH, 2), # [0, 2, 4, ...]
weight_method=WeightMethod.COSINE_SIMILARITY,
penetrable_limit=2,
directed=True,
)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vector_vis_graph-0.8.1.tar.gz.
File metadata
- Download URL: vector_vis_graph-0.8.1.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc10225131177c79755dc5c26bf9d8962071a3ea5f41a46c6ecb3b23588ccdb7
|
|
| MD5 |
475698b273acd23615f5dc2b8f2c6bdd
|
|
| BLAKE2b-256 |
0a965ffc2f25549cd8e887bccf714bce4f082f8ac0fa661ebae9840f8b25c245
|
Provenance
The following attestation bundles were made for vector_vis_graph-0.8.1.tar.gz:
Publisher:
python-publish.yml on tunakasif/vector-vis-graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vector_vis_graph-0.8.1.tar.gz -
Subject digest:
bc10225131177c79755dc5c26bf9d8962071a3ea5f41a46c6ecb3b23588ccdb7 - Sigstore transparency entry: 612776134
- Sigstore integration time:
-
Permalink:
tunakasif/vector-vis-graph@40436fa7d4b3144c356cf2b24801ee323b28b34b -
Branch / Tag:
refs/tags/0.8.1 - Owner: https://github.com/tunakasif
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@40436fa7d4b3144c356cf2b24801ee323b28b34b -
Trigger Event:
release
-
Statement type:
File details
Details for the file vector_vis_graph-0.8.1-py3-none-any.whl.
File metadata
- Download URL: vector_vis_graph-0.8.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fc76c421bec227cbc76deb41a012cd4716383f23aaa5a24d9338b5781166db5
|
|
| MD5 |
1ef9b3314588acb1dfc91eeab1ea4dfe
|
|
| BLAKE2b-256 |
3241869c013831e51633c6030f6f2e4ce1afcb9479b3161cbddd9567bef6fb7f
|
Provenance
The following attestation bundles were made for vector_vis_graph-0.8.1-py3-none-any.whl:
Publisher:
python-publish.yml on tunakasif/vector-vis-graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vector_vis_graph-0.8.1-py3-none-any.whl -
Subject digest:
5fc76c421bec227cbc76deb41a012cd4716383f23aaa5a24d9338b5781166db5 - Sigstore transparency entry: 612776165
- Sigstore integration time:
-
Permalink:
tunakasif/vector-vis-graph@40436fa7d4b3144c356cf2b24801ee323b28b34b -
Branch / Tag:
refs/tags/0.8.1 - Owner: https://github.com/tunakasif
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@40436fa7d4b3144c356cf2b24801ee323b28b34b -
Trigger Event:
release
-
Statement type: