Skip to main content

A simple module for outlier detection thanks to Modified Thompson Tau Test

Project description

Installation

mt3 requires Python 3.8+

To install the package run :

pip install mt3

If you are planing to use it with numpy and/or pandas, add optionnal dependencies :

pip install mt3[pandas, numpy] # or pip install mt3[numpy] for numpy only

mt3 will then be capable to deal with numpy.ndarray and pd.Series.

By default mt3 is provided with a table of Student T critical values. Available confidence levels are [0.9, 0.95, 0.975, 0.99, 0.995, 0.999]. To be able to use any confidence level, add scipy optionnal dependency :

pip install mt3[scipy]

Usage

mt3 main function is modified_thompson_tau_test :

from mt3 import modified_thompson_tau_test

sample = [-4, 3, -5, -2, 0, 1, 1000]

# You can use it with a simple list :

modified_thompson_tau_test(sample, 0.99)
# [False, False, False, False, False, False, True]


# But you can also use it with a numpy.ndarray or a pandas.Series
import numpy as np
import pandas as pd

modified_thompson_tau_test(np.array(sample), 0.99)
# [False False False False False False True] (numpy array)

modified_thompson_tau_test(pd.Series(sample), 0.99)
# [False False False False False False True] (numpy array)

# If you have nan values in your array or Series, you can choose to treat
# them as outliers
sample_with_nan = np.array([-4, np.nan, 3, -5, -2, 0, 1, 1000])

modified_thompson_tau_test(sample_with_nan, 0.99, nan_is_outlier=True)
# [False True False False False False False True] (numpy array)

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

mt3-0.2.1.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

mt3-0.2.1-py3-none-any.whl (7.2 kB view hashes)

Uploaded Python 3

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