{"id":21513883,"url":"https://github.com/jchiquet/aricode","last_synced_at":"2025-04-09T19:41:54.852Z","repository":{"id":57876642,"uuid":"67503068","full_name":"jchiquet/aricode","owner":"jchiquet","description":"R package for computation of (adjusted) rand-index and other such scores ","archived":false,"fork":false,"pushed_at":"2024-02-27T18:31:44.000Z","size":899,"stargazers_count":25,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-23T21:35:52.683Z","etag":null,"topics":["bucket-sort","clustering","clustering-comparison-measures"],"latest_commit_sha":null,"homepage":"https://jchiquet.github.io/aricode","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jchiquet.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-06T11:46:09.000Z","updated_at":"2024-05-29T21:43:16.000Z","dependencies_parsed_at":"2024-06-19T19:14:55.022Z","dependency_job_id":null,"html_url":"https://github.com/jchiquet/aricode","commit_stats":{"total_commits":102,"total_committers":7,"mean_commits":"14.571428571428571","dds":0.4117647058823529,"last_synced_commit":"fbd5d0d76422965d035fbe4b6006d475ccb74a19"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchiquet%2Faricode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchiquet%2Faricode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchiquet%2Faricode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchiquet%2Faricode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jchiquet","download_url":"https://codeload.github.com/jchiquet/aricode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248100809,"owners_count":21047851,"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":["bucket-sort","clustering","clustering-comparison-measures"],"created_at":"2024-11-23T23:35:52.075Z","updated_at":"2025-04-09T19:41:54.824Z","avatar_url":"https://github.com/jchiquet.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  fig.path = \"man/figures/\"\n)\n```\n\n# aricode\n\n \u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/jchiquet/aricode/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jchiquet/aricode/actions/workflows/R-CMD-check.yaml)\n[![CRAN Status](https://www.r-pkg.org/badges/version/aricode)](https://CRAN.R-project.org/package=aricode)\n[![Coverage status](https://codecov.io/gh/jchiquet/aricode/branch/master/graph/badge.svg)](https://codecov.io/gh/jchiquet/aricode)\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-blue.svg)](https://www.tidyverse.org/lifecycle/#stable)\n[![](https://img.shields.io/github/last-commit/jchiquet/aricode.svg)](https://github.com/jchiquet/aricode/commits/master)\n  \u003c!-- badges: end --\u003e\n\nA package for efficient computations of standard clustering comparison measures\n\n## Installation\n\nStable version on the [CRAN](https://cran.rstudio.com/web/packages/aricode/).\n\n```{r install_cran, eval = FALSE}\ninstall.packages(\"aricode\")\n```\n\nThe development version is available via:\n\n```{r install_github, eval = FALSE}\ndevtools::install_github(\"jchiquet/aricode\")\n```\n\n## Description\n\nComputation of measures for clustering comparison (ARI, AMI, NID and even the $\\chi^2$ distance) are usually based on the contingency table. Traditional implementations (e.g., function `adjustedRandIndex` of package **mclust**) are in $\\Omega(n + u v)$ where \n\n- $n$ is the size of the vectors the classifications of which are to be compared,\n- $u$ and $v$ are the respective number of classes in each vectors. \n\nIn **aricode** we propose an implementation, based on radix sort, that is in $\\Theta(n)$ in time and space.  \nImportantly, the complexity does not depends on $u$ and $v$.\nOur implementation of the ARI for instance is one or two order of magnitude faster than some standard implementation in `R`.\n\n## Available measures and functions\n\nThe functions included in aricode are:\n\n- `ARI`: computes the adjusted rand index\n- `Chi2`: computes the Chi-square statistics\n- `MARI/MARIraw`: computes the modified adjusted rand index (Sundqvist et al, in preparation)\n- `NVI`: computes the the normalized variation information\n- `NID`: computes the normalized information distance\n- `NMI`: computes the normalized mutual information\n- `AMI`: computes the adjusted mutual information\n- `expected_MI`: computes the expected mutual information\n- `entropy`: computes the conditional and joint entropies\n- `clustComp`: computes all clustering comparison measures at once\n\n## Timings\n\nHere are some timings to compare the cost of computing the adjusted Rand Index with **aricode** or with the commonly used function `adjustedRandIndex` of the *mclust* package: the cost of the latter can be prohibitive for large vectors: \n\n```{r timings_function, echo=FALSE, message=FALSE, warning=FALSE}\nlibrary(aricode)\nlibrary(mclust)\nlibrary(ggplot2)\n\ntime.aricode \u003c- function(times, c1, c2){\n  replicate(times, system.time(ARI(c1, c2))[3])\n}\n\ntime.mclust \u003c- function(times, c1, c2){\n  replicate(times, system.time(mclust::adjustedRandIndex(c1, c2))[3])\n}\n\ntime.method \u003c- function(times, c1, c2, n){\n  rbind(\n    data.frame(time = time.aricode(times, c1, c2), expr = \"aricode\", n = n),\n    data.frame(time = time.mclust(times, c1, c2), expr = \"mclust\", n = n)\n  )\n}\n\n# with similar classif, number of classes grows with n\nsim.timings \u003c- function(n, times = 10) {\n    c1 \u003c- sample(1:(n/200), n, replace=TRUE);c2 \u003c- c1;\n    i_change \u003c- sample(1:n, n/50, replace=FALSE)\n    c2[i_change] \u003c- c2[rev(i_change)]\n    out \u003c- time.method(times, c1, c2, n)\n    data.frame(time=out$time, method=out$expr, n = n)\n}\n```\n\n```{r timings_run, echo=FALSE, message=FALSE, warning=FALSE, cache=TRUE}\n# with similar classif, number of classes grows with n\nns \u003c- sort(c(200 * 2^(3:14), 150 * 2^(3:15)))\ntimings \u003c- do.call(\"rbind\", lapply(ns, sim.timings))\n```\n\n```{r timings_plot, echo=FALSE, message=FALSE, warning=FALSE}\np.timings \u003c- ggplot(timings, aes(x=n, y=time, colour=method)) +\n  geom_smooth(data = dplyr::filter(timings, n \u003e 1e4), method = \"lm\") + geom_point(size=0.25, alpha=0.9) + labs(y=\"time (sec.)\") +\n    scale_x_log10(\n   breaks = scales::trans_breaks(\"log10\", function(x) 10^x),\n   labels = scales::trans_format(\"log10\", scales::math_format(10^.x))\n ) +\n scale_y_log10(breaks = scales::trans_breaks(\"log10\", function(x) 10^x),\n   labels = scales::trans_format(\"log10\", scales::math_format(10^.x))) +\n   annotation_logticks()                 \n\np.timings + ggtitle(\"number of classes grows with n\") + theme_bw()\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchiquet%2Faricode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjchiquet%2Faricode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchiquet%2Faricode/lists"}