Skip to main content

QTS2D: Quantum-Based Image Encoding of Time Series

PyPI version PyPI - Downloads PyPI - Python Version License: BSD 3-Clause

QTS2D is a Python library for encoding time series data into image representations using quantum computing principles. These image-based representations can then be used as input for various machine learning models, particularly Convolutional Neural Networks (CNNs), for tasks like time series classification or forecasting.

Description

The library provides several quantum-inspired transformers that convert 1D time series into 2D matrices (images). These methods are analogous to classical time series imaging techniques but leverage quantum computations or quantum-inspired mathematical formulations.

Currently implemented transformers:

  • QGAF: Quantum Gramian Angular Field
  • QRP: Quantum Recurrence Plot
  • QSG: Quantum Spectrogram
  • QMTF: Quantum Markov Transition Field

Installation

You can install library using pip:

pip install qts2d

or using pip+git for the latest version of the code:

pip install git+

The library requires Python >= 3.10 and the following main dependencies:

  • numpy (>=2.2.5)
  • scikit-learn (>=1.6.1)
  • qiskit (==1.4.2)
  • qiskit-aer (==0.17.0)
  • qiskit-machine-learning (==0.8.2)
  • pyts (>=0.13.0)

Quick Example

Each transformer follows the scikit-learn Estimator and TransformerMixin interface.

import numpy as np
from qts2d.encoding import QGAF

# Example time series data (n_samples, n_timestamps)
X = np.random.rand(1, 1000)

# Using Quantum Gramian Angular Field (QGAF)
qgaf = QGAF(image_size=32, method='summation', computation_method='hadamard', scaling='minmax')
X_qgaf = qgaf.fit_transform(X)
print(f"QGAF output shape: {X_qgaf.shape}")

For more detailed examples, please refer to the examples/ directory for each specific transformer. To run the examples Matplotlib is required.

Contributing

We welcome everyone to contribute to qts2d! The library is still evolving and far from perfect, so your help is especially valuable. Please feel free to submit a pull request or open an issue. Detailed contribution guidelines will be shared soon along with the documentation. Stay tuned!

Citation

Coming soon!

License

This project is licensed under the BSD 3-Clause License - see the LICENSE.txt file for details.

References

  • [1] Xu, Z., Wang, Y., Feng, X., Wang, Y., Li, Y., & Lin, H. Quantum-enhanced forecasting: Leveraging quantum gramian angular field and CNNs for stock return predictions. Finance Research Letters (2024)

  • [2] Z. Wang and T. Oates, "Encoding Time Series as Images for Visual Inspection and Classification Using Tiled Convolutional Neural Networks." AAAI Workshop (2015).

  • [3] J.-P Eckmann, S. Oliffson Kamphorst and D Ruelle, "Recurrence Plots of Dynamical Systems". Europhysics Letters (1987).

Metadata

Release files for qts2d 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qts2d 0.1.0
File Size Uploaded
qts2d-0.1.0.tar.gz 55.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qts2d 0.1.0
File Interpreter ABI Platform
qts2d-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 85.3 kB

Release files / qts2d-0.1.0.tar.gz

Download URL qts2d-0.1.0.tar.gz
Size 55.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e7c1cf9d1871eb6e339b828d72ea1cbaa6ff9b32bce0d153aa493d5deadca932
BLAKE2b-256 checksum
How to use checksums
d488498f78064e5ce61a312c26a2a6dd4424c577f77e861ff40c8f7739cca693
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 8, 2025.

Transparency log

Release files / qts2d-0.1.0-py3-none-any.whl

Download URL qts2d-0.1.0-py3-none-any.whl
Size 30.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74932fff0367cbf7a47d5e94395512e086772d69e539c99d5081059aa907c57d
BLAKE2b-256 checksum
How to use checksums
08b0d6752cb6cda8f3fe88891f2585197204e4da97cc2ff9374ceda2b139361c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 8, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page