Skip to main content

Python package for applying automatic error detection algorithms to time series. Create custom error detection algorithms to support data validation workflows.

Project description

traval Documentation Status Codacy Badge Codacy Badge PyPI

traval

Tools for applying automatic error detection algorithms to time series.

Introduction

This module is set up to provide tools for applying any error detection algorithm to any time series. The module consists of three main components:

  • RuleSet: the RuleSet object is a highly flexible object for defining error detection algorithms based on (user-defined) functions.
  • Detector: a data management object for storing time series and error detection results.
  • SeriesComparison*: objects for comparing time series. These objects include plots for visualizing the comparisons.

The general workflow consists of the following steps:

  1. Define error detection algorithm(s).
  2. Load data, i.e. raw time series data and optionally time series representing the "truth" to see how well the algorithms perform.
  3. Initialize Detector objects and apply algorithms to time series.
  4. Store and analyze the results.

For more detailed information and examples, please refer to the notebooks in the examples directory.

Installation

To install the traval module, follow these steps:

  1. Clone the repository from GitHub.
  2. Open a terminal and navigate to the module root directory: <your path here>/traval
  3. Type pip install -e .

Usage

The basic usage of the module is described below. To start using the module, import the package:

import traval

The first step is generally to define an error detection algorithm. This is done with the RuleSet object:

ruleset = traval.RuleSet("my_first_algorithm")

Add a detection rule (using a general rule from the library contained within the module). In this case the rule states any value above 10.0 is suspect:

ruleset.add_rule(
    "rule1",
    traval.rulelib.rule_ufunc_threshold,
    apply_to=0,
    kwargs={"ufunc": (np.greater,), "threshold": 10.0}
)

Take a look at the ruleset by just typing ruleset:

ruleset
RuleSet: 'my_first_algorithm'
  step: name            apply_to
     1: rule1                  0

Next define a Detector object. This object is designed to store a time series and the intermediate and final results after applying an error detection algorithm. Initialize the Detector object with some time series. In this example we assume there is a time series called raw_series:

>>> detect = traval.Detector(raw_series)

Apply our first algorithm to the time series.

>>> detect.apply_ruleset(ruleset)

By default, the result of each step in the algorithm is compared to the original series and stored in the detect.comparisons attribute. Take a look at the comparison between the raw data and the result of the error detection algorithm.

Since we only defined one step, step 1 represents the final result.

>>> cp = detect.comparisons[1]  # result of step 1 = final result

The SeriesComparison* objects contain methods to visualize the comparison, or summarize the number of observations in each category:

>>> cp.plots.plot_series_comparison()  # plot a comparison
>>> cp.summary  # series containing number of observations in each category

For more detailed explanation and more complex examples, see the notebook(s) in the examples directory.

Author

  • D.A. Brakenhoff, Artesia, 2020

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

traval-0.5.1.tar.gz (42.3 kB view details)

Uploaded Source

Built Distribution

traval-0.5.1-py3-none-any.whl (38.9 kB view details)

Uploaded Python 3

File details

Details for the file traval-0.5.1.tar.gz.

File metadata

  • Download URL: traval-0.5.1.tar.gz
  • Upload date:
  • Size: 42.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for traval-0.5.1.tar.gz
Algorithm Hash digest
SHA256 322a36629e6a31ffdd0a0ba22a1e900d2881511a8a830f8e966120abbfe2c411
MD5 93ab8011336cf1b7d7278e76dcfc6bd3
BLAKE2b-256 c5e6633d14b1c51637b88cd413ee99bab694c99dec302e934b1b32bf87d62b4a

See more details on using hashes here.

File details

Details for the file traval-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: traval-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 38.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for traval-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f774105706241d0ea2fcd06a7112c2d4bab0562b36b9fe1ca93bc3c070067897
MD5 b0c54db652253f494f86c51b7bffc086
BLAKE2b-256 11d24a0a60386c5f129381fb61cad62a96aca8e359f97e94c5a7b143af40fb49

See more details on using hashes here.

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