Skip to main content

A description of your project

Project description

pyanomaly

Conjunto de algoritmos para detectar anomalias em Series Temporais.

Instalação

pip install pyanomaly

Como usar

Iremos realizar os testes no dataset contendo temperaturas diarias da cidade de Melbourne.

dataset: https://raw.githubusercontent.com/jbrownlee/Datasets/master/daily-min-temperatures.csv

# data
import numpy as np
import pandas as pd
# plot
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()

df = pd.read_csv('./dados/daily-min-temperatures.csv', parse_dates=['Date'])
df.set_index('Date', inplace=True)
print(df.head(5).T)
Date  1981-01-01  1981-01-02  1981-01-03  1981-01-04  1981-01-05
Temp        20.7        17.9        18.8        14.6        15.8
df.plot(figsize=(8, 4));

png

Mad

mad = MAD()
mad.fit(df['Temp'])
outliers = mad.fit_predict(df['Temp'])

outliers.head()
Date
1981-01-15    25.0
1981-01-18    24.8
1981-02-09    25.0
1982-01-17    24.0
1982-01-20    25.2
Name: Temp, dtype: float64
fig, ax = plt.subplots(1, 1, figsize=(12, 6))

sns.lineplot(x=df.index, y=df['Temp'], ax=ax)
sns.scatterplot(x=outliers.index, y=outliers, 
                color='r', ax=ax)

plt.title('Zscore Robusto', fontsize='large');

png

Tukey

tu = Tukey()

tu.fit(df['Temp'])
outliers = tu.predict(df['Temp'])

outliers.head()
Date
1981-01-15    25.0
1981-01-18    24.8
1981-02-09    25.0
1982-01-17    24.0
1982-01-20    25.2
Name: Temp, dtype: float64
fig, ax = plt.subplots(1, 1, figsize=(12, 6))

sns.lineplot(x=df.index, y=df['Temp'], ax=ax)
sns.scatterplot(x=outliers.index, y=outliers, 
                color='r', ax=ax)

plt.title('Tukey Method', fontsize='large');

png

Twitter - S-MAD

outliers = twitter(df['Temp'], period=12)
outliers.head()
Date
1981-01-15    25.0
1981-01-18    24.8
1981-02-09    25.0
1982-01-20    25.2
1982-02-15    26.3
Name: Temp, dtype: float64
fig, ax = plt.subplots(1, 1, figsize=(12, 6))

sns.lineplot(x=df.index, y=df['Temp'], ax=ax)
sns.scatterplot(x=outliers.index, y=outliers, 
                color='r', ax=ax)

plt.title('Tukey Method', fontsize='large');

png

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

pyanomaly-0.0.1.0.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

pyanomaly-0.0.1.0.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file pyanomaly-0.0.1.0.1.tar.gz.

File metadata

  • Download URL: pyanomaly-0.0.1.0.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for pyanomaly-0.0.1.0.1.tar.gz
Algorithm Hash digest
SHA256 0adccaaf11aeccc4b73e7f16be9df6a63a65ad320c0bbdc14bc0260d2192a0bc
MD5 dccddf345bb133d73198c9adeb65d4b1
BLAKE2b-256 76e66d83781b1d552de4bd6080c5cd644743a62ba2a302b2f3cdcfa382dceac6

See more details on using hashes here.

File details

Details for the file pyanomaly-0.0.1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyanomaly-0.0.1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for pyanomaly-0.0.1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4231b8b1a8b92d2e902fc6f6b61f0454f955386de4d11ae9194bc5fbafa034fd
MD5 2ffcd11f0654044ec1ee9986de6de922
BLAKE2b-256 6ebedbdac1139181dccb5df4bb6d5207b6eb91a663a5c8d1f52ffe7fca79570a

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