drvi.utils.metrics.most_similar_averaging_score

drvi.utils.metrics.most_similar_averaging_score#

drvi.utils.metrics.most_similar_averaging_score(result_matrix)[source]#

Compute the most similar averaging score for disentanglement evaluation.

This function calculates the average of the maximum scores across all target variables. It measures how well the each of the targets can be captured by any of the latent dimensions.

Parameters:

result_matrix (ndarray) – Matrix of metric scores with shape (n_dimensions, n_categories). Each element [i, j] represents the score for dimension i and category j.

Return type:

float

Returns:

float The average of maximum scores across all categories. Higher values indicate better disentanglement.

Notes

The function computes: 1. For each target variable, finds the dimension with the highest score 2. Takes the average of these maximum scores across all target variables

This approach treats each target variable equally and measures the average performance of the best-matching dimensions. It’s a simple but effective way to assess overall disentanglement quality.

Mathematical formula: ` score = mean(max(result_matrix[:, j]) for j in range(n_categories)) `

Examples

>>> import numpy as np
>>> # Example result matrix (4 dimensions, 3 categories)
>>> result_matrix = np.array(
...     [
...         [0.9, 0.1, 0.9],
...         [0.1, 0.9, 0.1],
...         [0.1, 0.1, 0.9],
...         [0.1, 0.9, 0.1],
...     ]
... )
>>> score = most_similar_averaging_score(result_matrix)
>>> print(f"MSAS score: {score:.3f}")  # 0.933