This release is a pre-release and may not be stable for production use.
pyanom
This library is Python projects for anomaly detection. This contains these techniques.
Kullback-Leibler desity estimation
Singular spectrum analysis
Graphical lasso
CUMSUM anomaly detection
Hoteling T2
Directional data anomaly detection
REQUIREMENTS
numpy
pandas
scikit-learn
scipy
INSTALLATION
pip install pyanom
USAGE
Kullback-Leibler desity estimation
import numpy as np
from pyanom.density_ratio_estimation import KLDensityRatioEstimator
X_normal = np.loadtxt("./data/normal_data.csv", delimiter=",")
X_error = np.loadtxt("./data/error_data.csv", delimiter=",")
model = KLDensityRatioEstimator(
band_width=h, lr=0.001, max_iter=100000)
model.fit(X_normal, X_error)
anomaly_score = model.score(X_normal, X_error)
Singular spectrum analysis
import numpy as np
from pyanom.subspace_methods import SSA
y_error = np.loadtxt("./data/timeseries_error2.csv", delimiter=",")
model = SSA(window_size=50, trajectory_n=25, trajectory_pattern=3, test_n=25, test_pattern=2, lag=25)
model.fit(y_error)
anomaly_score = model.score()
Graphical lasso
import numpy as np
from pyanom.structure_learning import GraphicalLasso
X_normal = np.loadtxt("./data/normal_data.csv", delimiter=",")
X_error = np.loadtxt("./data/error_data.csv", delimiter=",")
model = GraphicalLasso(rho=0.1)
model.fit(X_normal)
anomaly_score = model.score(X_error)
Direct learning sparse changes
from pyanom.structure_learning import DirectLearningSparseChanges
model = DirectLearningSparseChanges(
lambda1=0.1, lambda2=0.3, max_iter=10000)
model.fit(X_normal, X_error)
pmatrix_diff = model.get_sparse_changes()
CUSUM anomaly detection
import numpy as np
from pyanom.outlier_detection import CAD
y_normal = np.loadtxt(
"./data/timeseries_normal.csv", delimiter=",").reshape(-1, 1)
y_error = np.loadtxt(
"./data/timeseries_error.csv", delimiter=",").reshape(-1, 1)
model = CAD(threshold=1.0)
model.fit(y_normal)
anomaly_score = model.score(y_error)
Hoteling T2
import numpy as np
from pyanom.outlier_detection import HotelingT2
X_normal = np.loadtxt("./data/normal_data.csv", delimiter=",")
X_error = np.loadtxt("./data/error_data.csv", delimiter=",")
model = HotelingT2()
model.fit(X_normal)
anomaly_score = model.score(X_error)
Directional data anomaly DirectionalDataAnomalyDetection
import numpy as np
from pyanom.outlier_detection import AD3
X_normal = np.loadtxt(
"./data/normal_direction_data.csv", delimiter=",")
X_error = np.loadtxt("./data/error_direction_data.csv", delimiter=",")
model = AD3()
model.fit(X_normal, normalize=True)
anomaly_score = model.score(X_error)
Metadata
Release files for pyanom 0.0.2b1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyanom-0.0.2b1.tar.gz | 10.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyanom-0.0.2b1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.7 kB
Release files / pyanom-0.0.2b1.tar.gz
| Download URL | pyanom-0.0.2b1.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4c476040f1a72f83742933bd49db2c833ac58f88f48e76f3db97729bdf2546c
|
|
BLAKE2b-256 checksum How to use checksums |
a5f8e422d15cb2812b94125523472dc40a9aa00564722bcebe8b7ac4042c9c02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
|
Release files / pyanom-0.0.2b1-py3-none-any.whl
| Download URL | pyanom-0.0.2b1-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0dc0801fe0528e4c4d306e33692a96eea9ff070a44fc2ffc6ec00200004c8298
|
|
BLAKE2b-256 checksum How to use checksums |
fffb7f145a626a433d66d97784b7a07e0e24678346810ede26852549a34ba5e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
|
Security for pyanom 0.0.2b1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.