Skip to main content

Simple implementation of the Temporal Outlier Factor

Project description

Documentation Status https://travis-ci.com/phrenico/uniqed.svg?branch=master https://coveralls.io/repos/github/phrenico/uniqed/badge.svg?branch=master

The uniqed package

Simple python implementation of the Temporal Outlier Factor [1] (TOF) anomaly detection method.

Installation instructions

Install it directly from PyPI:

pip install uniqed

Simple example

This is a simple example:

from uniqed.data.gen_logmap import generate_logmapdata
from uniqed.runners.tof_run import detect_outlier
import matplotlib.pyplot as plt

# Generate some data
data_df = generate_logmapdata(rseed=359)

# Detect outliers
res_df = detect_outlier(data_df[['value']], cutoff_n=80)


# plot the results
fig, axs = plt.subplots(2, 1, sharex=True)
fig.suptitle('TOF anomaly detection demo')

axs[0].plot(res_df['value'], color='tab:blue', label='time series')
axs[0].plot(res_df['value'].loc[data_df.query("is_anomaly==1").index.values],
         color='tab:green', label='anomaly')
axs[0].plot(res_df.query("TOF==1")['value'], lw=0, marker='o',
         color='tab:orange', label='TOF detections')
axs[0].set_ylabel('values')
axs[0].legend(loc='upper left', framealpha=1)


axs[1].plot(res_df['TOF_score'], color='k', label='TOF score')
axs[1].plot(res_df['TOF_score'].loc[data_df.query("is_anomaly==1").index.values],
         color='tab:green', label='anomaly')
axs[1].plot(res_df.query("TOF==1")['TOF_score'], lw=0, marker='o',
         color='tab:orange', label='TOF')
axs[1].set_ylabel('TOF score')
axs[1].set_xlabel('t')
axs[1].legend(['TOF score', 'anomaly', 'TOF detections'],
              loc='upper left',
              framealpha=1)

axs[1].set_xlim(0, 2000)
axs[0].grid(True)
axs[1].grid(True)

fig.tight_layout(rect=[0, 0, 1, 1], pad=1, h_pad=0, w_pad=0)
fig.savefig("example_run.png")
plt.show()
https://raw.githubusercontent.com/phrenico/uniqed/master/examples/example_run.png

References

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

uniqed-0.0.2.tar.gz (477.4 kB view details)

Uploaded Source

Built Distribution

uniqed-0.0.2-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file uniqed-0.0.2.tar.gz.

File metadata

  • Download URL: uniqed-0.0.2.tar.gz
  • Upload date:
  • Size: 477.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for uniqed-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2d272b965504548e5a51e929830d7432c8dca020329cf9f18761462da8b2d6be
MD5 355838b0dd92847352c235bbbeb387f0
BLAKE2b-256 52cfb46b90a56d28b3d31a0f64697337abbd2cc1e41b3aae3dd64c647f3ba9ef

See more details on using hashes here.

File details

Details for the file uniqed-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: uniqed-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for uniqed-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9a1952525473619b9d3f6ef56f8f3b3e3d1f71cbd990914a9d703975038f36c8
MD5 5ed5a24dd987d056ee28e29ecfba7f9d
BLAKE2b-256 2e70555cdd5528aa5547e020d240327a7b869024e535e7cd623895c0957b06e8

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