{"id":13528546,"url":"https://github.com/predict-idlab/GENDIS","last_synced_at":"2025-04-01T13:33:14.272Z","repository":{"id":32809304,"uuid":"142547104","full_name":"predict-idlab/GENDIS","owner":"predict-idlab","description":"Contains an implementation (sklearn API) of the algorithm proposed in \"GENDIS: GEnetic DIscovery of Shapelets\" and code to reproduce all experiments.","archived":false,"fork":false,"pushed_at":"2023-07-06T21:23:55.000Z","size":165534,"stargazers_count":105,"open_issues_count":11,"forks_count":25,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-21T21:44:57.070Z","etag":null,"topics":["data-mining","evolutionary-algorithms","shapelets","time-series-analysis","timeseries-analysis"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/predict-idlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-07-27T08:00:38.000Z","updated_at":"2025-01-11T11:07:34.000Z","dependencies_parsed_at":"2022-08-28T04:40:46.248Z","dependency_job_id":"ee91d05a-79aa-4c58-903b-bb29e6cef0fe","html_url":"https://github.com/predict-idlab/GENDIS","commit_stats":{"total_commits":162,"total_committers":6,"mean_commits":27.0,"dds":"0.20370370370370372","last_synced_commit":"4d955b7cc9c9e1af23462bf81bcd8110e30c184d"},"previous_names":["predict-idlab/gendis","ibcnservices/gendis"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predict-idlab%2FGENDIS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predict-idlab%2FGENDIS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predict-idlab%2FGENDIS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predict-idlab%2FGENDIS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/predict-idlab","download_url":"https://codeload.github.com/predict-idlab/GENDIS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246647827,"owners_count":20811392,"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":["data-mining","evolutionary-algorithms","shapelets","time-series-analysis","timeseries-analysis"],"created_at":"2024-08-01T07:00:20.998Z","updated_at":"2025-04-01T13:33:12.923Z","avatar_url":"https://github.com/predict-idlab.png","language":"Jupyter Notebook","readme":"# GENDIS [![Build Status](https://travis-ci.org/IBCNServices/GENDIS.svg?branch=master)](https://travis-ci.org/IBCNServices/GENDIS) [![PyPI version](https://badge.fury.io/py/GENDIS.svg)](https://badge.fury.io/py/GENDIS) [![Read The Docs](https://readthedocs.org/projects/gendis/badge/?version=latest)](https://gendis.readthedocs.io/en/latest/?badge=latest) [![Downloads](https://pepy.tech/badge/gendis)](https://pepy.tech/project/gendis)\n## GENetic DIscovery of Shapelets \n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"GENDIS.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"evolving_shaps.gif\"\u003e\n\u003c/p\u003e\n\nIn the time series classification domain, shapelets are small subseries that are discriminative for a certain class. It has been shown that by projecting the original dataset to a distance space, where each axis corresponds to the distance to a certain shapelet, classifiers are able to achieve state-of-the-art results on a plethora of datasets.\n\nThis repository contains an implementation of `GENDIS`, an algorithm that searches for a set of shapelets in a genetic fashion. The algorithm is insensitive to its parameters (such as population size, crossover and mutation probability, ...) and can quickly extract a small set of shapelets that is able to achieve predictive performances similar (or better) to that of other shapelet techniques.\n\n## Installation\n\nWe currently support Python 3.5 \u0026 Python 3.6. For installation, there are two alternatives:\n\n1. Clone the repository `https://github.com/IBCNServices/GENDIS.git` and run `(python3 -m) pip -r install requirements.txt`\n2. GENDIS is hosted on PyPi. You can just run `(python3 -m) pip install gendis` to add gendis to your dist-packages (you can use it from everywhere).\n\n**Make sure NumPy and Cython is already installed (`pip install numpy` and `pip install Cython`), since that is required for the setup script.**\n\n## Tutorial \u0026 Example\n\n### 1. Loading \u0026 preprocessing the datasets\n\nIn a first step, we need to construct at least a matrix with timeseries (`X_train`) and a vector with labels (`y_train`). Additionally, test data can be loaded as well in order to evaluate the pipeline in the end.\n\n```python\nimport pandas as pd\n# Read in the datafiles\ntrain_df = pd.read_csv(\u003cDATA_FILE\u003e)\ntest_df = pd.read_csv(\u003cDATA_FILE\u003e)\n# Split into feature matrices and label vectors\nX_train = train_df.drop('target', axis=1)\ny_train = train_df['target']\nX_test = test_df.drop('target', axis=1)\ny_test = test_df['target']\n```\n\n### 2. Creating a `GeneticExtractor` object\n\nConstruct the object. For a list of all possible parameters, and a description, please refer to the documentation in the [code](gendis/genetic.py)\n\n```python\nfrom gendis.genetic import GeneticExtractor\ngenetic_extractor = GeneticExtractor(population_size=50, iterations=25, verbose=True, \n                                     mutation_prob=0.3, crossover_prob=0.3, \n                                     wait=10, max_len=len(X_train) // 2)\n```\n\n### 3. Fit the `GeneticExtractor` and construct distance matrix\n\n```python\nshapelets = genetic_extractor.fit(X_train, y_train)\ndistances_train = genetic_extractor.transform(X_train)\ndistances_test = genetic_extractor.transform(X_test)\n```\n\n### 4. Fit ML classifier on constructed distance matrix\n\n```python\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.metrics import accuracy_score\nlr = LogisticRegression()\nlr.fit(distances_train, y_train)\n\nprint('Accuracy = {}'.format(accuracy_score(y_test, lr.predict(distances_test))))\n```\n\n### Example notebook\n\nA simple example is provided in [this notebook](gendis/example.ipynb)\n\n## Data\n\nAll datasets in this repository are downloaded from [timeseriesclassification](http://timeseriesclassification.com). Please refer to them appropriately when using any dataset.\n\n## Paper experiments\n\nIn order to reproduce the results from the corresponding paper, please check out [this directory](gendis/experiments).\n\n## Tests\n\nWe provide a few doctests and unit tests. To run the doctests: `python3 -m doctest -v \u003cFILE\u003e`, where `\u003cFILE\u003e` is the Python file you want to run the doctests from. To run unit tests: `nose2 -v`\n\n## Contributing, Citing and Contact\n\nIf you have any questions, are experiencing bugs in the GENDIS implementation, or would like to contribute, please feel free to create an issue/pull request in this repository or take contact with me at gilles(dot)vandewiele(at)ugent(dot)be\n\nIf you use GENDIS in your work, please use the following citation:\n```bibtex\n@article{vandewiele2021gendis,\n  title={GENDIS: Genetic Discovery of Shapelets},\n  author={Vandewiele, Gilles and Ongenae, Femke and Turck, Filip De},\n  journal={Sensors},\n  volume={21},\n  number={4},\n  pages={1059},\n  year={2021},\n  publisher={Multidisciplinary Digital Publishing Institute}\n}\n```\n","funding_links":[],"categories":["Libraries"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpredict-idlab%2FGENDIS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpredict-idlab%2FGENDIS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpredict-idlab%2FGENDIS/lists"}