{"id":21732082,"url":"https://github.com/antixk/sgmrfmix","last_synced_at":"2025-04-13T00:36:08.459Z","repository":{"id":53467766,"uuid":"329408866","full_name":"AntixK/sGMRFmix","owner":"AntixK","description":"A Python library for sGMRFmix model for anomaly detection in time series","archived":false,"fork":false,"pushed_at":"2021-03-29T23:11:58.000Z","size":12392,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-13T00:36:03.537Z","etag":null,"topics":["anomaly-detection","cpp","graphical-lasso","machine-learning","python3","sgmrfmix","sparse-modeling","sparse-representations","time-series","variational-bayes"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AntixK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-13T19:19:38.000Z","updated_at":"2023-12-29T13:30:05.000Z","dependencies_parsed_at":"2022-09-09T20:11:50.434Z","dependency_job_id":null,"html_url":"https://github.com/AntixK/sGMRFmix","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntixK%2FsGMRFmix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntixK%2FsGMRFmix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntixK%2FsGMRFmix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntixK%2FsGMRFmix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AntixK","download_url":"https://codeload.github.com/AntixK/sGMRFmix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650420,"owners_count":21139671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anomaly-detection","cpp","graphical-lasso","machine-learning","python3","sgmrfmix","sparse-modeling","sparse-representations","time-series","variational-bayes"],"created_at":"2024-11-26T04:28:43.612Z","updated_at":"2025-04-13T00:36:08.439Z","avatar_url":"https://github.com/AntixK.png","language":"Jupyter Notebook","readme":"# sGMRFmix\n\n[![Build Status](https://travis-ci.com/AntixK/sGMRFmix.svg?branch=dev)](https://travis-ci.com/AntixK/sGMRFmix)\n\nPython library for sGMRFmix model for anomaly detection in time-series data.\nsGMRFmix is short for sparse mixture of Gaussian Markov Random Fields.\nThis is essentially a C++ (and python) port of the R package [`sGMRFmix`](https://cran.r-project.org/web/packages/sGMRFmix/index.html) to make it run faster for larger datasets.\n\n## Model Overview\nsGMRFmix is a mixture of GMRFs that predict the likelihood of a random variable using the variables in its markov blanket. Lower the log likelihood, higher the anomaly score. The markov blanket is estimated using a Gaussian graphical model with constraint that enforces sparsity in the inverse covariance matrices of the mixture of GMRF model. This can be done in a stright-forward manner using Graphical LASSO model. You can check out the [paper](https://ide-research.net/papers/2016_ICDM_Ide.pdf) for further details and the math.\n  \n![sGMRFmix Model](https://github.com/AntixK/sGMRFmix/blob/main/assets/model_overview.png)\n\n## Performance Comparison\nThe follwing plot shows the performance comparison with the only [`sGMRFmix`](https://cran.r-project.org/web/packages/sGMRFmix/index.html) library available publicaly in R language.\n \n![sGMRFmix Model](https://github.com/AntixK/sGMRFmix/blob/dev/assets/sgmrf_comparison.png)\n\n## Installation\n\n### Requirements\n- Python \u003e= 3.6 (For Python Thread-Specific-Storage (TSS) API used by pybind11)\n- Numpy \u003e= 1.16.5\n\n### Binaries\nCheck out the releases of this repo for wheels for various platforms.\nInstall the wheel using pip inside your python environment.\n```\npip install sgmrfmix-\u003cplatform/other tags\u003e.whl\n```\n\n\n### Build from source\nFor Linux\n```\nsudo apt-get update\nsudo apt-get install libopenblas-dev liblapack-dev libarpack2-dev libsuperlu-dev\nsudo apt install libarmadillo-dev libboost-all-dev build-essential\n```\n\nFor Mac\n```\nbrew install cmake pkg-config boost openblas \nbrew install armadillo \n```\n\nClone the repository (including the pybind11 submodule) into a suitable directory\n```\ngit clone --recursive git@github.com:AntixK/sGMRFmix.git\ncd sGMRFmix\n```\nBuild the C++ files\n```\ncd build\ncmake ..\nmake\n```\nInstall requirements and build the library.\nOptionally create a python virtual environment to install the library.\n```\ncd ..\npip install -r requirements.txt\npython setup.py install\n\npip install auditwheel\nauditwheel show dist/sgmrfmix-0.1-cp37-cp37m-linux_x86_64.whl\nauditwheel repair --plat linux_x86_64  dist/sgmrfmix-0.1-cp37-cp37m-linux_x86_64.whl\n\n## Usage\n```python\nimport numpy as np\nfrom sgmrfmix import sGMRFmix\n\nm = sGMRFmix(K = 5, rho=0.8)\ntrain = np.genfromtxt('train.csv', delimiter=',', skip_header=True)[:, 1:]\ntest = np.genfromtxt('test.csv', delimiter=',', skip_header=True)[:, 1:]\n\nm.fit(train)\nm.show_model_params()\nresults = m.compute_anomaly(test)\n```\n\nCheck out further examples in the `Examples/` folder.\n\n\n## Acknowledgements\n- T. Ide, A .Khandelwal, J .Kalagnanam, **Sparse Gaussian Markov Random Field Mixtures for Anomaly Detection**, IEEE 16th International Conference on Data Mining (ICDM), 2016, pp 955–960\n- https://rdrr.io/cran/sGMRFmix/f/vignettes/sGMRFmix.Rmd\n- https://cran.r-project.org/web/packages/sGMRFmix/vignettes/sGMRFmix.html\n- https://github.com/cran/sGMRFmix\n- https://github.com/JClavel/glassoFast\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantixk%2Fsgmrfmix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantixk%2Fsgmrfmix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantixk%2Fsgmrfmix/lists"}