Skip to main content

A library for temporal sequence simulation.

Project description


title: TSeqMock - Temporal Sequence Mocking

Synopsis

TSeqMock is a Python library for temporal sequence simulation.

Features

  • Multiple Generation Types: Supports three main types of temporal data:

    • Event: Sequences of point events in time
    • State: Sequences of successive states
    • Interval: Sequences of time intervals with variable durations
  • Configurable Generation: Full customization of statistical distributions, generation methods, and time strategies

  • Missing Data: Ability to integrate missing values to simulate real-world cases

  • Multiple Profiles: Creation of multiple data profiles with different configurations

Links

Installation

pip install tseqmock

Usage Examples

Generating Event Sequences

from datetime import timedelta
import numpy as np
from tseqmock.core import TSeqMocker
from tseqmock.generator.base.profile import Profile
from tseqmock.generator.type.event.time_design import EventTimeDesign
from tseqmock.method.base import GenMethod
from tseqmock.time_strategy.base import TimeStrategy
from tseqmock.distribution.base import Distribution

# Initialize the event generator
mock = TSeqMocker("event")

# Configure the generation method
gen_method = GenMethod.init("random")
gen_method.update_settings(vocabulary=np.random.uniform(0, 1, 100))

# Add a profile
mock.add_profile(
    Profile(
        n_seq=10,  # Number of sequences to generate
        sequence_size=4,  # Sizes of the sequences
        data_cols={"event": gen_method},  # Data columns
        missing_data={"event": 0.05},  # Missing data configuration - 5% missing
    )
)

# Configure the time strategy
time_strat = TimeStrategy.init("fixed")
time_strat.update_settings(
    t0_date="2025-01-01",
    # Number of days between sampling (T0, T0+7, T0+7+25, T0+7+25+62)
    # This is equivalent to T0, T0+1 week, T0+1 month, T0+3 months
    sampling_steps=[7, 25, 62],
    granularity="day",
)

# Define time design
mock.set_time_design(
    time_design_settings=EventTimeDesign(
        t0_strategy=time_strat,
        sampling_strategy=time_strat,
    )
)

# Generate data
data = mock()
print(data)
print(mock.summary)

Generating State Sequences

from tseqmock.generator.type.state.time_design import StateTimeDesign

# Initialize the state generator
mock = TSeqMocker("state")

# Configure the generation method
gen_method = GenMethod.init("random")
gen_method.update_settings(vocabulary=["HEALTHY", "SICK", "REMISSION"])

# Add a profile
mock.add_profile(
    Profile(
        n_seq=10,
        sequence_size=[3, 4, 9, 3, 5],
        data_cols={"state": gen_method},
        missing_data={"state": 0},
    )
)

# Configure the time strategy
distrib = Distribution.init("normal", settings={"mu": 3, "sigma": 100})
time_strat = TimeStrategy.init("sequence_specific")
time_strat.update_settings(
    distribution=distrib,
    min_date="1980-01-01",
    max_date="2026-01-01",
)

# Define time design
mock.set_time_design(
    time_design_settings=StateTimeDesign(
        t0_strategy=time_strat,
        sampling_strategy=time_strat,
    )
)

# Generate data
data = mock()
print(data)
print(mock.summary)

Generating Interval Sequences

from tseqmock.generator.type.interval.time_design import IntervalTimeDesign

# Initialize the interval generator
mock = TSeqMocker("interval")

# Configure the generation method
gen_method = GenMethod.init("random")
gen_method.update_settings(vocabulary=[
    "RESTING",
    "RESTAURANT",
    "CITY TOUR",
    "SHOPPING",
])

# Add a profile
mock.add_profile(
    Profile(
        n_seq=10,
        sequence_size=[3, 4, 9, 3, 5],
        data_cols={"interval": gen_method},
    )
)

# Configure the time strategy
time_strat = TimeStrategy.init("sequence_specific")
time_strat.update_settings(
    distribution="uniform",
    min_date="2025-07-01",
    max_date="2025-08-01",
)

# Possible interval durations
interval_durations = [1, 2, 3, 4]
# Define time design
mock.set_time_design(
    time_design_settings=IntervalTimeDesign(
        t0_strategy=time_strat,
        sampling_strategy=time_strat,
        interval_durations=interval_durations,
        granularity="hour",
    )
)

# Generate data
data = mock()
print(data)
print(mock.summary)

Advanced Customization

TSeqMock offers various customization options:

  • Statistical Distributions: Normal, uniform, etc.
  • Time Strategies: Sequence-specific, periodic, etc.
  • Generation Methods: Random, rule-based, etc.

Contributors and Contact

This project was initiated as a student collaboration within the AIstroSight Inria Team.

Student Contributors

The following M1 Bioinformatics students from Université Claude Bernard Lyon 1 contributed to the development during their coursework:

  • GAGNIEU Thomas
  • GUEYE Ndeye
  • RIOU Baptiste
  • SEBAI Imene

Core Team

  • Arnaud Duvermy - Lead Developer & Technical Architect
  • Thomas Guyet - Project Leader & Maintainer

Contact: thomas.guyet@inria.fr

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

tseqmock-0.2.1.tar.gz (47.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tseqmock-0.2.1-py3-none-any.whl (47.0 kB view details)

Uploaded Python 3

File details

Details for the file tseqmock-0.2.1.tar.gz.

File metadata

  • Download URL: tseqmock-0.2.1.tar.gz
  • Upload date:
  • Size: 47.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tseqmock-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c9c380fde257ea4a06d0c09676cfac3edad3bd444143bcf90299a65fe95c06f6
MD5 70aacd45d9c6043f455b3bf9913f5dff
BLAKE2b-256 1463ac308b87d8ba471066ebd5545e6329c0137f3e95ce246de8d1417da64fc1

See more details on using hashes here.

File details

Details for the file tseqmock-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: tseqmock-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 47.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tseqmock-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2ac9710b128190885ae037ead65ac42c3eaa0ad3af1a44699b9c78ef4572dce1
MD5 d386a88ec361174c07d8c8d5579ef16c
BLAKE2b-256 f7b33cccd3de8ce4c188c7936444b4baa79f81c04dd4ed5ad00e8defc9cdd941

See more details on using hashes here.

Supported by

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