{"id":15482770,"url":"https://github.com/ap6yc/cvi","last_synced_at":"2025-04-22T15:41:32.544Z","repository":{"id":58813428,"uuid":"526280198","full_name":"AP6YC/cvi","owner":"AP6YC","description":"A Python package implementing both batch and incremental cluster validity indices.","archived":false,"fork":false,"pushed_at":"2024-06-21T15:34:45.000Z","size":1442,"stargazers_count":4,"open_issues_count":8,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2024-11-24T19:35:42.632Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/AP6YC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-18T16:00:47.000Z","updated_at":"2024-06-06T07:20:10.000Z","dependencies_parsed_at":"2024-01-09T17:28:23.142Z","dependency_job_id":"43f4538b-931f-4b8c-92ed-e266ebb2c7c3","html_url":"https://github.com/AP6YC/cvi","commit_stats":{"total_commits":167,"total_committers":2,"mean_commits":83.5,"dds":"0.053892215568862256","last_synced_commit":"c6cc3e03a02315e096e3898634348a20ee9f41c3"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AP6YC%2Fcvi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AP6YC%2Fcvi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AP6YC%2Fcvi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AP6YC%2Fcvi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AP6YC","download_url":"https://codeload.github.com/AP6YC/cvi/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250269951,"owners_count":21402968,"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":[],"created_at":"2024-10-02T05:09:58.855Z","updated_at":"2025-04-22T15:41:32.486Z","avatar_url":"https://github.com/AP6YC.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![cvi-header](https://github.com/AP6YC/FileStorage/blob/main/cvi/header.png?raw=true)][docs-dev-url]\n\nA Python package implementing both batch and incremental cluster validity indices (CVIs).\n\n| **Stable Docs**  | **Dev Docs** | **Build Status** | **Coverage** |\n|:----------------:|:------------:|:----------------:|:------------:|\n| [![Stable][docs-stable-img]][docs-stable-url] | [![Dev][docs-dev-img]][docs-dev-url]| [![Build Status][ci-img]][ci-url] | [![Codecov][codecov-img]][codecov-url] |\n| **Version** | **Issues** | **Downloads** | **Zenodo DOI** |\n| [![version][version-img]][version-url] | [![issues][issues-img]][issues-url] | [![Downloads][downloads-img]][downloads-url] |  [![DOI][zenodo-img]][zenodo-url] |\n\n[downloads-img]: https://static.pepy.tech/badge/cvi\n[downloads-url]: https://pepy.tech/project/cvi\n\n[zenodo-img]: https://zenodo.org/badge/526280198.svg\n[zenodo-url]: https://zenodo.org/badge/latestdoi/526280198\n\n[docs-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg\n[docs-stable-url]: https://AP6YC.github.io/cvi/main\n\n[docs-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg\n[docs-dev-url]: https://AP6YC.github.io/cvi/develop\n\n[ci-img]: https://github.com/AP6YC/cvi/actions/workflows/Test.yml/badge.svg\n[ci-url]: https://github.com/AP6YC/cvi/actions/workflows/Test.yml\n\n[codecov-img]: https://codecov.io/gh/AP6YC/cvi/branch/main/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/AP6YC/cvi\n\n[version-img]: https://img.shields.io/pypi/v/cvi.svg\n[version-url]: https://pypi.org/project/cvi\n\n[issues-img]: https://img.shields.io/github/issues/AP6YC/cvi?style=flat\n[issues-url]: https://github.com/AP6YC/cvi/issues\n\n## Table of Contents\n\n- [Table of Contents](#table-of-contents)\n- [Cluster Validity Indices](#cluster-validity-indices)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Quickstart](#quickstart)\n  - [Detailed Usage](#detailed-usage)\n- [Implemented CVIs](#implemented-cvis)\n- [History](#history)\n- [Acknowledgements](#acknowledgements)\n  - [Derivation](#derivation)\n  - [Authors](#authors)\n  - [Related Projects](#related-projects)\n  - [Assets](#assets)\n    - [Fonts](#fonts)\n    - [Icons](#icons)\n\n## Cluster Validity Indices\n\nSay you have a clustering algorithm that clusters a set of samples containing features of some kind and some dimensionality.\nGreat!\nThat was a lot of work, and you should feel accomplished.\nBut how do you know that the algorithm performed _well_?\nBy definition, you wouldn't have the _true_ label belonging to each sample (if one could even exist in your context), just the label prescribed by your clustering algorithm.\n\n**Enter Cluster Validity Indices (CVIs)**.\n\nCVIs are metrics of cluster partitioning when true cluster labels are unavailable.\nEach operates on only the information available (i.e., the provided samples of features and the labels prescribed by the clustering algorithm) and produces a _metric_, a number that goes up or down according to how well the CVI believes the clustering algorithm appears to, well, _cluster_.\nClustering well in this context means correctly partitioning (i.e., separating) the data rather than prescribing too many different clusters (over partitioning) or too few (under partitioning).\nEvery CVI itself also behaves differently in terms of the range and scale of their numbers.\n**Furthermore, each CVI has an original batch implementation and incremental implementation that are equivalent**.\n\nThe `cvi` Python package contains a variety of these batch and incremental CVIs.\n\n## Installation\n\nThe `cvi` package is listed on PyPI, so you may install the latest version with\n\n```python\npip install cvi\n```\n\nYou can also specify a version to install in the usual way with\n\n```python\npip install cvi==v0.6.0\n```\n\nAlternatively, you can manually install a release from the [releases page](https://github.com/AP6YC/cvi/releases) on GitHub.\n\n## Usage\n\n### Quickstart\n\nCreate a CVI object and compute the criterion value in batch with `get_cvi`:\n\n```python\n# Import the library\nimport cvi\n# Create a Calinski-Harabasz (CH) CVI object\nmy_cvi = cvi.CH()\n# Load some data from some clustering algorithm\nsamples, labels = load_some_clustering_data()\n# Compute the final criterion value in batch\ncriterion_value = my_cvi.get_cvi(samples, labels)\n```\n\nor do it incrementally, also with `get_cvi`:\n\n```python\n# Datasets are numpy arrays\nimport numpy as np\n# Create a container for criterion values\nn_samples = len(labels)\ncriterion_values = np.zeros(n_samples)\n# Iterate over the data\nfor ix in range(n_samples):\n    criterion_values = my_cvi.get_cvi(samples[ix, :], labels[ix])\n```\n\n### Detailed Usage\n\nThe `cvi` package contains a set of implemented CVIs with batch and incremental update methods.\nEach CVI is a standalone stateful object inheriting from a base class `CVI`, and all `CVI` functions are object methods, such as those that update parameters and return the criterion value.\n\nInstantiate a CVI of you choice with the default constructor:\n\n```python\n# Import the package\nimport cvi\n# Import numpy for some data handling\nimport numpy as np\n\n# Instantiate a Calinski-Harabasz (CH) CVI object\nmy_cvi = cvi.CH()\n```\n\nCVIs are instantiated with their acronyms, with a list of all implemented CVIS being found in the [Implemented CVIs](#implemented-cvis) section.\n\nA batch of data is assumed to be a numpy array of samples and a numpy vector of integer labels.\n\n```python\n# Load some data\nsamples, labels = my_clustering_alg(some_data)\n```\n\n\u003e **NOTE**:\n\u003e\n\u003e The `cvi` package assumes the Numpy **row-major** convention where rows are individual samples and columns are features.\n\u003e A batch dataset is then `[n_samples, n_features]` large, and their corresponding labels are `[n_samples]` large.\n\nYou may compute the final criterion value with a batch update all at once with `CVI.get_cvi`\n\n```python\n# Get the final criterion value in batch mode\ncriterion_value = my_cvi.get_cvi(samples, labels)\n```\n\nor you may get them incrementally with the same method, where you pass instead just a single numpy vector of features and a single integer label.\nThe incremental methods are used automatically based upon the dimensions of the data that is passed.\n\n```python\n# Create a container for the criterion value after each sample\nn_samples = len(labels)\ncriterion_values = np.zeros(n_samples)\n\n# Iterate across the data and store the criterion value over time\nfor ix in range(n_samples):\n    sample = samples[ix, :]\n    label = labels[ix]\n    criterion_values[ix] = my_cvi.get_cvi(sample, label)\n```\n\n\u003e **NOTE**:\n\u003e\n\u003e Currently only using _either_ batch _or_ incremental methods is supported; switching from batch to incremental updates with the same is not yet implemented.\n\n## Implemented CVIs\n\nThe following CVIs have been implemented as of the latest version of `cvi`:\n\n- **CH**: Calinski-Harabasz\n- **cSIL**: Centroid-based Silhouette\n- **DB**: Davies-Bouldin\n- **GD43**: Generalized Dunn's Index 43.\n- **GD53**: Generalized Dunn's Index 53.\n- **PS**: Partition Separation.\n- **rCIP**: (Renyi's) representative Cross Information Potential.\n- **WB**: WB-index.\n- **XB**: Xie-Beni.\n\n## History\n\n- 8/18/2022: Initialize project.\n- 9/8/2022: First release on PyPi and initiate GitFlow.\n- 8/10/2023: v0.5.1 released.\n- 5/31/2024: Updated documentation.\n\n## Acknowledgements\n\n### Derivation\n\nThe incremental and batch CVI implementations in this package are largely derived from the following Julia language implementations by the same authors of this package:\n\n- [ClusterValidityIndices.jl](https://github.com/AP6YC/ClusterValidityIndices.jl)\n\n### Authors\n\nThe principal authors of the `cvi` pacakge are:\n\n- Sasha Petrenko \u003cpetrenkos@mst.edu\u003e\n- Nik Melton \u003cnmmz76@mst.edu\u003e\n\n### Related Projects\n\nIf this package is missing something that you need, feel free to check out some related Python cluster validity packages:\n\n- [validclust](https://github.com/crew102/validclust)\n- [clusterval](https://github.com/Nuno09/clusterval)\n\n### Assets\n\n#### Fonts\n\nThe following font is used in the logo:\n\n- [Ethnocentric Font Family](https://www.1001fonts.com/ethnocentric-font.html)\n\n#### Icons\n\nThe icon for the project is taken from:\n\n- [Cluster computing icons created by IconBaandar - Flaticon](https://www.flaticon.com/free-icons/cluster-computing) ([cluster-5464694](https://www.flaticon.com/free-icon/cluster_5464694))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fap6yc%2Fcvi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fap6yc%2Fcvi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fap6yc%2Fcvi/lists"}