Rand and Adjusted Rand Index Calculator for Cluster Analysis

Version 1.0.0 (303 KB) by qqffssxx
An efficient MATLAB function for computing the Rand Index (RI) and Adjusted Rand Index (ARI),
203 Downloads
Updated 9 Jun 2023

View License

This function, named randindex, allows users to calculate two crucial statistical measures, the Rand Index (RI) and the Adjusted Rand Index (ARI), which are commonly used for comparing the similarity between two data clusterings. The function is compatible with any numerical labels used for clustering and returns both the RI and ARI values for easy performance comparison and clustering evaluation.
In clustering tasks, measuring the quality and the reliability of the results is essential. The Rand Index (RI) measures the percentage of decisions that are consistent between two clusterings, while the Adjusted Rand Index (ARI) corrects the RI by the chance grouping of elements, providing a more robust statistic for comparing different clustering algorithms or methods.
Usage is straightforward. Simply provide two same-length vectors of labels, representing two different clustering results, and the function will return the corresponding RI and ARI values.
The function was thoroughly tested against Python's sklearn library metrics, ensuring its accuracy and reliability.
Example usage:
labels1 = [1 1 2 3 2 1 1 3 2 2];
labels2 = [2 2 3 1 3 2 2 1 3 3];
[RI, ARI] = randindex(labels1, labels2);
disp(['RI: ', num2str(RI)]);
disp(['ARI: ', num2str(ARI)]);
We hope you find this function useful in your data analysis tasks.

Cite As

qqffssxx (2024). Rand and Adjusted Rand Index Calculator for Cluster Analysis (https://www.mathworks.com/matlabcentral/fileexchange/130779-rand-and-adjusted-rand-index-calculator-for-cluster-analysis), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2018a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: Adjusted Rand Index

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0