Skip to main content

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

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

Metadata

Release files for TSeqMock 0.2.1

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

Source distribution (sdist)

Source distribution for TSeqMock 0.2.1
File Size Uploaded
tseqmock-0.2.1.tar.gz 47.5 kB Details

Built distribution (wheel)

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

Total release size: 94.5 kB

Release files / tseqmock-0.2.1.tar.gz

Download URL tseqmock-0.2.1.tar.gz
Size 47.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c9c380fde257ea4a06d0c09676cfac3edad3bd444143bcf90299a65fe95c06f6
BLAKE2b-256 checksum
How to use checksums
1463ac308b87d8ba471066ebd5545e6329c0137f3e95ce246de8d1417da64fc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / tseqmock-0.2.1-py3-none-any.whl

Download URL tseqmock-0.2.1-py3-none-any.whl
Size 47.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ac9710b128190885ae037ead65ac42c3eaa0ad3af1a44699b9c78ef4572dce1
BLAKE2b-256 checksum
How to use checksums
f7b33cccd3de8ce4c188c7936444b4baa79f81c04dd4ed5ad00e8defc9cdd941
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

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