Skip to main content

Infer daily rhythm and sleep schedule from message timestamps

Project description

parcae

PyPI License

Blog

Infer daily rhythm and sleep schedule from message timestamps

parcae is a command-line tool and Python library that analyzes nothing but timestamps and infers a user's likely timezone offset and their typical sleep window.

How It Works

parcae models human behavior as a very small Hidden Markov Model with two hidden states:

  • Awake (A)
  • Sleep (S)

The only observation is "was there at least one message in this time bin?". The model is trained globally across many users to learn:

  • how likely people are to send messages while "awake"
  • how unlikely they are to send messages while "asleep"
  • how often they switch between the two states

At inference time, Parcae:

  1. Tries many possible timezone offsets
  2. Picks the offset that makes the timeline most explainable by a "human with one long sleep per day"
  3. Decodes the most likely sleep/awake sequence
  4. Extracts daily sleep blocks
  5. Computes a typical schedule and regularity statistics

Installation

You can install parcae using pipx:

pipx install parcae

Usage

API

from parcae import Parcae

p = Parcae()

timestamps = [
    "2025-09-01T05:43:12+00:00",
    "2025-09-01T18:22:10+00:00",
    ...
]

print(p.analyze(timestamps))

CLI

Parcae expects a CSV file with one user's timestamps:

timestamp
2025-09-01T05:43:12+00:00
2025-09-01T07:58:33+00:00
2025-09-01T18:22:10+00:00
parcae analyze user_timestamps.csv

Compare two fingerprints to estimate whether they belong to the same person:

parcae compare parcae:v1:<fp1> parcae:v1:<fp2>

Examples

+ Parcae analysis

~ inferred timezone: UTC+3

+ typical schedule:
        - sleep: 23:52 -> 06:34  ( 8h 30m)
        - awake: 06:34 -> 23:52
        - variability: ±175m

+ activity profile (24h):
        ▁▁▁▁▁▁▁▁▅▇▅█▆▁▅▄▅▆▁▇▇▆▆▇
        |     |     |     |     
        00    06    12    18    

+ fingerprint:
        parcae:v1:AAAAAAAAAAAAAAAAAAAAAD0AWQA6AGMAQQAAADoAMAA6AEcAAABWAFUATgBMAFsAd__-D9QPqP12BPEBqwU=

~ based on 30 days of data
~ bin size: 15 minutes

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

parcae-0.2.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

parcae-0.2.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: parcae-0.2.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for parcae-0.2.1.tar.gz
Algorithm Hash digest
SHA256 bca9658576c40e33ce4bf7330219cba9f9bcb4671848a874ed32316636b12fb6
MD5 f1a4df99129bf48816e694a0eba583a3
BLAKE2b-256 449d9fdcc022ba37c120dc1f7494f641f8a6ba377373df903951d1c43acae9b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: parcae-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for parcae-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4df6e0fc4655b222d08fbee6e54659213a6e82f3131726ad0084c4c26af96da0
MD5 22701d2c46b917577c97184366236c36
BLAKE2b-256 c0b785b3a85e847c044cd322ecb1667e878a480e08f04b236cc1e7488bf2fddc

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