Package smile.validation.metric
Class NormalizedMutualInformation
java.lang.Object
smile.validation.metric.NormalizedMutualInformation
- All Implemented Interfaces:
Serializable
,ClusteringMetric
Normalized Mutual Information (NMI) for comparing clustering.
Normalized mutual information is between 0 (no mutual information)
and 1 (perfect correlation). Normalization has been
shown to improve the sensitiveness with respect to the
difference in cluster distribution in the two clusterings.
References
- X. Vinh, J. Epps, J. Bailey. Information Theoretic Measures for Clusterings Comparison: Variants, Properties, Normalization and Correction for Chance. JMLR, 2010.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The normalization method. -
Field Summary
Modifier and TypeFieldDescriptionstatic final NormalizedMutualInformation
Default instance with max normalization.static final NormalizedMutualInformation
Default instance with max normalization.static final NormalizedMutualInformation
Default instance with min normalization.static final NormalizedMutualInformation
Default instance with sqrt normalization.static final NormalizedMutualInformation
Default instance with sum normalization. -
Constructor Summary
ConstructorDescriptionConstructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic double
joint
(int[] y1, int[] y2) Calculates the normalized mutual information of I(y1, y2) / H(y1, y2).static double
max
(int[] y1, int[] y2) Calculates the normalized mutual information of I(y1, y2) / max(H(y1), H(y2)).static double
min
(int[] y1, int[] y2) Calculates the normalized mutual information of I(y1, y2) / min(H(y1), H(y2)).double
score
(int[] y1, int[] y2) Returns a score to measure the quality of clustering.static double
sqrt
(int[] y1, int[] y2) Calculates the normalized mutual information of I(y1, y2) / sqrt(H(y1) * H(y2)).static double
sum
(int[] y1, int[] y2) Calculates the normalized mutual information of 2 * I(y1, y2) / (H(y1) + H(y2)).toString()
-
Field Details
-
JOINT
Default instance with max normalization. -
MAX
Default instance with max normalization. -
MIN
Default instance with min normalization. -
SUM
Default instance with sum normalization. -
SQRT
Default instance with sqrt normalization.
-
-
Constructor Details
-
NormalizedMutualInformation
Constructor.- Parameters:
method
- the normalization method.
-
-
Method Details
-
score
public double score(int[] y1, int[] y2) Description copied from interface:ClusteringMetric
Returns a score to measure the quality of clustering.- Specified by:
score
in interfaceClusteringMetric
- Parameters:
y1
- the ground truth (or simply a clustering labels).y2
- the alternative cluster labels.- Returns:
- the metric.
-
joint
public static double joint(int[] y1, int[] y2) Calculates the normalized mutual information of I(y1, y2) / H(y1, y2).- Parameters:
y1
- the clustering labels.y2
- the alternative cluster labels.- Returns:
- the metric.
-
max
public static double max(int[] y1, int[] y2) Calculates the normalized mutual information of I(y1, y2) / max(H(y1), H(y2)).- Parameters:
y1
- the clustering labels.y2
- the alternative cluster labels.- Returns:
- the metric.
-
sum
public static double sum(int[] y1, int[] y2) Calculates the normalized mutual information of 2 * I(y1, y2) / (H(y1) + H(y2)).- Parameters:
y1
- the clustering labels.y2
- the alternative cluster labels.- Returns:
- the metric.
-
sqrt
public static double sqrt(int[] y1, int[] y2) Calculates the normalized mutual information of I(y1, y2) / sqrt(H(y1) * H(y2)).- Parameters:
y1
- the clustering labels.y2
- the alternative cluster labels.- Returns:
- the metric.
-
min
public static double min(int[] y1, int[] y2) Calculates the normalized mutual information of I(y1, y2) / min(H(y1), H(y2)).- Parameters:
y1
- the clustering labels.y2
- the alternative cluster labels.- Returns:
- the metric.
-
toString
-