Skip to main content

pyvoi: Variation of Information in numpy/torch

Calculate the Variation of Information for two clusterings

References: Meila, Marina (2003). Comparing Clusterings by the Variation of Information. Learning Theory and Kernel Machines: 173–187

Installation

pip install python-voi

Usage

By default, pyvoi uses torch to compute the variation of information.

To get VI values only

import pyvoi
labels1=[0,1,1,2,4]
labels2=[0,2,3,4,4]
vi,vi_split,vi_merge=pyvoi.VI(labels1,labels2)
print(vi,vi_split,vi_merge)
# total vi, split vi, merge vi
# tensor(0.5545) tensor(0.2773) tensor(0.2773)

To get VI components

import pyvoi
labels1=[0,1,1,2,4]
labels2=[0,2,3,4,4]
vi,vi_split,vi_merge,splitters,mergers=pyvoi.VI(labels1,labels2,return_split_merge=True)
print(vi,vi_split,vi_merge)
# (same as above) total vi, split vi, merge vi
# tensor(0.5545) tensor(0.2773) tensor(0.2773)

print(splitters)
# vi contribution, label in label2
#tensor([[0.2773, 4.0000],
#    [0.0000, 3.0000],
#    [0.0000, 2.0000],
#    [0.0000, 0.0000]])

print(mergers)
# vi contribution, label in label1
#tensor([[0.2773, 1.0000],
#    [0.0000, 4.0000],
#    [0.0000, 2.0000],
#    [0.0000, 0.0000]])

Using cuda

import pyvoi
labels1=[0,1,1,2,4]
labels2=[0,2,3,4,4]
vi,vi_split,vi_merge=pyvoi.VI(labels1,labels2,device="cuda")
print(vi,vi_split,vi_merge)
#tensor(0.5545, device='cuda:0') tensor(0.2773, device='cuda:0') tensor(0.2773, device='cuda:0')

Using numpy

import numpy as np
import pyvoi
labels1=np.array([0,1,1,2,4])
labels2=np.array([0,2,3,4,4])
vi,vi_split,vi_merge=pyvoi.VI(labels1,labels2,torch=False)
print(vi,vi_split,vi_merge)
#0.5545177444479561 0.27725887222397794 0.27725887222397816

Contact and Bug Reports

Core Francisco Park: cfpark00@gmail.com

Metadata

Release files for python-voi 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-voi 0.0.3
File Size Uploaded Provenance
python-voi-0.0.3.tar.gz 3.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for python-voi 0.0.3
File Interpreter ABI Platform
python_voi-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 4.8 kB

Release files / python-voi-0.0.3.tar.gz

Download URL python-voi-0.0.3.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6be0e61dccc35da429fc57161702a40ab6d8c6c3a28a529e4ae1d49826136bc1
BLAKE2b-256 checksum
How to use checksums
43b95d246fe49d1727e162fe85afb101e5963d1bd8f16a2a78465f0f39a1856c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.13

Release files / python_voi-0.0.3-py3-none-any.whl

Download URL python_voi-0.0.3-py3-none-any.whl
Size 1.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63612cf00b0c48d2ec270c6d63fc685990595c6c630745b4f0871309a652cfdc
BLAKE2b-256 checksum
How to use checksums
dcf9509a8dec2a0197c74d4d8f58778a8e466c0c4fade0f9ca46f07b0d895b3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.13

Security for python-voi 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page