Skip to main content

A package for chronicle recognition

Project description

PyChronicle package

A chronicle is a specification of the complex temporal behaviors as a temporal constraint graph. It can be used to recognize complex behaviors in sequence the temporal events.

A chronicle is a multiset of events and a set of temporal constraints specifying that occurrences of pairs of events must occurs within a given temporal interval.

The package implements the model of chronicles and an efficient algorithm to recognize it.

There are three different ways to recognize chronicle in a sequence of a events:

  • the absence/presence recognition (c.isrecognize(seq)): its result is a boolean stating whether the chronicle occur at least once in the sequence, this is the most efficient algorithm
  • the occurrence enumeration (c.recognize(seq)): its result is a list of occurrence of the chronicle in a sequence. Contrary to the first implementation, it looks for all possible combinasion of events. Thus it is less efficient
  • the approximate occurrence enumeration (c.cmp(seq, 0.7)): its result is a list of occurrences that are similar of the chronicle with a similarity threshold of 0.7.

Please note that the author is not fully sasitfied by the function name and that it appeals to change them in a short delay ...

Requirements

Use pip install -r requirements.txt to install requirements.

Naturally, the latter may require superuser rights (consider prefixing the commands by sudo).

If you want to use Python 3 and your system defaults on Python 2.7, you may need to adjust the above commands, e.g., replace pip by pip3.

The required libraries are the following

  • numpy
  • scipy
  • lazr.restfulclient
  • larz.uri

LAZR is used to instantiate chronicles from CRS files (with simple grammar).

Usage

Example of usage:

from pychronicles import *
#define a sequence of events
seq = [3,4,'b','a','a',1,3,'coucou','b','coucou',5,'coucou',5]

#define a chronicle
c=Chronicle()
c.add_event(0,'b')
c.add_event(1,1)
c.add_constraint(1,3, (3,45))
print(c)

#recognize the chronicle in the sequence
occs=c.recognize(seq)
print("occurrences: "+str(occs))

It is possible to specify chronicles using the CRS format. The following code illustrate the syntax for specifying a chronicle in this format.

chronicle C27_sub_0[]()
{
    event(Event_Type1[], t006)
    event(Event_Type1[], t004)
    event(Event_Type2[], t002)
    event(Event_Type3[], t001)

    t004-t006 in [17,25]
    t006-t002 in [-16,-10]
    t002-t001 in [14,29]
    t004-t001 in [27,35]
}

Authorship

Author: Thomas Guyet Institution: AGROCAMPUS-OUEST/IRISA date:10/2019

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

pychronicles-0.0.4.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

pychronicles-0.0.4-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file pychronicles-0.0.4.tar.gz.

File metadata

  • Download URL: pychronicles-0.0.4.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for pychronicles-0.0.4.tar.gz
Algorithm Hash digest
SHA256 24bca0c797dc8dba723942b8700da2f50decc473c6416972822b1666a2ad4976
MD5 e7f5395ebd364e2b3f9676d347745076
BLAKE2b-256 159b4925cf9eb750af87bc506f4311169d99bd9099967d74844a38d5113d05d6

See more details on using hashes here.

Provenance

File details

Details for the file pychronicles-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pychronicles-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for pychronicles-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 62b7a3f4205fd5691cc73838279c686badfb77eb2b93fcbe8ec6ba2d72482e4f
MD5 841dca251805fb608216c3f121e5d32c
BLAKE2b-256 e57af7eef5acdc67e5c136a659fe2c2334e4d86c39458c480e90d118b98559d2

See more details on using hashes here.

Provenance

Supported by

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