Skip to content

Utility library for detecting and removing outliers from normally distributed datasets

License

Notifications You must be signed in to change notification settings

faddey-w/outlier-utils

 
 

Repository files navigation

outlier-utils

https://travis-ci.org/c-bata/outlier-utils.svg?branch=master

Utility library for detecting and removing outliers from normally distributed datasets using the Smirnov-Grubbs test.

Requirements

Overview

Both the two-sided and the one-sided version of the test are supported. The former allows extracting outliers from both ends of the dataset, whereas the latter only considers min/max outliers. When running a test, every outlier will be removed until none can be found in the dataset. The output of the test is flexible enough to match several use cases. By default, the outlier-free data will be returned, but the test can also return the outliers themselves or their indices in the original dataset.

Examples

  • Two-sided Grubbs test with a Pandas series input
>>> from outliers import smirnov_grubbs as grubbs
>>> import pandas as pd
>>> data = pd.Series([1, 8, 9, 10, 9])
>>> grubbs.test(data, alpha=0.05)
1     8
2     9
3    10
4     9
dtype: int64
  • Two-sided Grubbs test with a NumPy array input
>>> import numpy as np
>>> data = np.array([1, 8, 9, 10, 9])
>>> grubbs.test(data, alpha=0.05)
array([ 8,  9, 10,  9])
  • One-sided (min) test returning outlier indices
>>> grubbs.min_test_indices([8, 9, 10, 1, 9], alpha=0.05)
[3]
  • One-sided (max) tests returning outliers
>>> grubbs.max_test_outliers([8, 9, 10, 1, 9], alpha=0.05)
[]
>>> grubbs.max_test_outliers([8, 9, 10, 50, 9], alpha=0.05)
[50]

License

This software is licensed under the MIT License.

About

Utility library for detecting and removing outliers from normally distributed datasets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%