# trendalation
An anomaly detection package for all sorts of trends & time series data. The library leverages algorithms like procrustes analysis to compare and contrast the general shape & trajectory of different trends. The **procrustses analysis** technique could be leveraged to get the minimum possible mean squared error between 2 distributions (after mathematical transformations). Using the training dataset, an ideal reference trace is determined for comparision along with a classification threshold from the generated error distribution using procrustes against this reference curve.
<img width="718" alt="before_proc_demo" src="https://github.com/kartikeysinha/trendalation/assets/44055129/54e6dc93-33b8-4890-a086-5e624aff1dc3">
<img width="718" alt="after_proc_demo" src="https://github.com/kartikeysinha/trendalation/assets/44055129/5802bb69-9695-4403-9d9e-1f8c02f59ce3">
## Installation
### Dependencies
trendalation requires:
- Python (>= 3.8)
- NumPy (>= 1.25.0)
- Scikit-Learn (>=1.3.0)
- SciPy (>= 1.11.1)
### Using pip
The easiest way to install trendalation is using pip:
`pip install trendalation`
## Documentation
### Usage
To train a classifier on a collection of traces, a classifier can be trained on the trace distribution. The model sets up the necessary classification criterion by analyzing various population statistics and trends. eg-
```python
from trendalation.classification import ProcClassifier
clf = ProcClassifier()
clf.fit()
```
To futher optimize the process to the classification criterion determination, additional (optional) training parameters can be provided-
- **y:** The target values (binary class labels) as integers with 1 representing an anomaly. If provided, classifier is fitted only on "good" samples in an attempt to get higher errors with "bad" samples against the reference curve.
- **threshold:** Provide a percentile value to determine the threshold value on the procrustes error distribution.
- **normalize:** Option to normalize traces with respect to themselves before fitting. Useful when traces have highly variables ranges. For example, stock prices.
- **ci_width:** Confidence interval width parameter. Useful for approximating the location of the divergence or the anomaly on a trace.
The procrustes and trace normalizing functionality can be directly imported from the metric module-
```python
from trendalation.metrics import procrustes
trace1_transformed, trace2_transformed, disparity = procrustes(trace1, trace2)
```
## Help and Support
In order to report bugfixes and new feature requests, simply create a new issue on the repository.
The issues will be reviewed by the authors on a regular basis & you're welcome to work on any open issues.
## Contribution
This project is a community effort, and everyone is welcome to contribute.
Feel free to work on any open issues and setup PRs.
Raw data
{
"_id": null,
"home_page": "https://github.com/kartikeysinha/trendalation",
"name": "trendalation",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "anomaly detection,time-series,procrustes,trends,spatial analysis",
"author": "['Raghav Saboo', 'Kartikey Sinha']",
"author_email": "raghs2000@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/03/f5/c33d677df475e2b0c770851abd5286e39f8d3bf15461944bb8919b9185fe/trendalation-1.0.2.tar.gz",
"platform": null,
"description": "# trendalation\n\nAn anomaly detection package for all sorts of trends & time series data. The library leverages algorithms like procrustes analysis to compare and contrast the general shape & trajectory of different trends. The **procrustses analysis** technique could be leveraged to get the minimum possible mean squared error between 2 distributions (after mathematical transformations). Using the training dataset, an ideal reference trace is determined for comparision along with a classification threshold from the generated error distribution using procrustes against this reference curve.\n\n<img width=\"718\" alt=\"before_proc_demo\" src=\"https://github.com/kartikeysinha/trendalation/assets/44055129/54e6dc93-33b8-4890-a086-5e624aff1dc3\">\n<img width=\"718\" alt=\"after_proc_demo\" src=\"https://github.com/kartikeysinha/trendalation/assets/44055129/5802bb69-9695-4403-9d9e-1f8c02f59ce3\">\n\n## Installation\n\n### Dependencies\n\ntrendalation requires:\n\n- Python (>= 3.8)\n- NumPy (>= 1.25.0)\n- Scikit-Learn (>=1.3.0)\n- SciPy (>= 1.11.1)\n\n### Using pip\n\nThe easiest way to install trendalation is using pip:\n`pip install trendalation`\n\n## Documentation\n\n### Usage\n\nTo train a classifier on a collection of traces, a classifier can be trained on the trace distribution. The model sets up the necessary classification criterion by analyzing various population statistics and trends. eg-\n\n```python\nfrom trendalation.classification import ProcClassifier\nclf = ProcClassifier()\nclf.fit()\n```\n\nTo futher optimize the process to the classification criterion determination, additional (optional) training parameters can be provided-\n\n- **y:** The target values (binary class labels) as integers with 1 representing an anomaly. If provided, classifier is fitted only on \"good\" samples in an attempt to get higher errors with \"bad\" samples against the reference curve.\n- **threshold:** Provide a percentile value to determine the threshold value on the procrustes error distribution.\n- **normalize:** Option to normalize traces with respect to themselves before fitting. Useful when traces have highly variables ranges. For example, stock prices.\n- **ci_width:** Confidence interval width parameter. Useful for approximating the location of the divergence or the anomaly on a trace.\n\nThe procrustes and trace normalizing functionality can be directly imported from the metric module-\n\n```python\nfrom trendalation.metrics import procrustes\ntrace1_transformed, trace2_transformed, disparity = procrustes(trace1, trace2)\n```\n\n## Help and Support\n\nIn order to report bugfixes and new feature requests, simply create a new issue on the repository.\nThe issues will be reviewed by the authors on a regular basis & you're welcome to work on any open issues.\n\n## Contribution\n\nThis project is a community effort, and everyone is welcome to contribute.\nFeel free to work on any open issues and setup PRs.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "",
"version": "1.0.2",
"project_urls": {
"Homepage": "https://github.com/kartikeysinha/trendalation"
},
"split_keywords": [
"anomaly detection",
"time-series",
"procrustes",
"trends",
"spatial analysis"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "799acf3745efd517377504488b85466621488322d9df6150394821db9c0233a4",
"md5": "b66ce01b9903ec4fc04d5e8e3d19f838",
"sha256": "d996108f56fb1b9822f8ae88bbfcb76acdcbbab4cba647ab8c53fde9c0ca8c00"
},
"downloads": -1,
"filename": "trendalation-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b66ce01b9903ec4fc04d5e8e3d19f838",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6545,
"upload_time": "2023-08-12T21:23:37",
"upload_time_iso_8601": "2023-08-12T21:23:37.569149Z",
"url": "https://files.pythonhosted.org/packages/79/9a/cf3745efd517377504488b85466621488322d9df6150394821db9c0233a4/trendalation-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "03f5c33d677df475e2b0c770851abd5286e39f8d3bf15461944bb8919b9185fe",
"md5": "57a31f927b5f63afbeaf6946270aa11e",
"sha256": "4b030755256a723a27086b06876f4cc35c0283d0e9101c22753e4aaea426e942"
},
"downloads": -1,
"filename": "trendalation-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "57a31f927b5f63afbeaf6946270aa11e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6801,
"upload_time": "2023-08-12T21:23:39",
"upload_time_iso_8601": "2023-08-12T21:23:39.152432Z",
"url": "https://files.pythonhosted.org/packages/03/f5/c33d677df475e2b0c770851abd5286e39f8d3bf15461944bb8919b9185fe/trendalation-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-12 21:23:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kartikeysinha",
"github_project": "trendalation",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "numpy",
"specs": [
[
"==",
"1.25.0"
]
]
},
{
"name": "scikit-learn",
"specs": [
[
"==",
"1.3.0"
]
]
},
{
"name": "scipy",
"specs": [
[
"==",
"1.11.1"
]
]
},
{
"name": "pytest",
"specs": [
[
"==",
"7.4.0"
]
]
}
],
"lcname": "trendalation"
}