hatvis.similarity.pairwise_profile_similarity#

hatvis.similarity.pairwise_profile_similarity(X, measure='jaccard')[source]#

Similarity between the rows of a non-negative profile matrix X.

For rows \(\mathbf{a},\mathbf{b}\) with entries \(a_e,b_e\ge0\):

  • "jaccard" (weighted Jaccard / Ruzicka): \(\sum_e\min(a_e,b_e)/\sum_e\max(a_e,b_e)\), the classical Jaccard coefficient \(|e_a\cap e_b|/|e_a\cup e_b|\) for 0/1 rows;

  • "dice": \(2\sum_e\min(a_e,b_e)/(\sum_e a_e+\sum_e b_e)\);

  • "overlap": \(\sum_e\min(a_e,b_e)/\min(\sum_e a_e,\sum_e b_e)\);

  • "cosine": \(\mathbf{a}^\mathsf{T}\mathbf{b}/(\|\mathbf{a}\|\|\mathbf{b}\|)\);

  • "inclusion" (asymmetric): \(\sum_e\min(a_e,b_e)/\sum_e a_e\) — how much of row a is covered by row b;

  • "hamming": one minus the fraction of positions where the 0/1 patterns differ;

  • "count": \(\sum_e\min(a_e,b_e)\) (shared hyperedges, not normalized).

The diagonal is 1 for non-empty rows (0 for empty rows, except hamming).