Class: Rumale::EvaluationMeasure::NormalizedMutualInformation
- Inherits:
-
Object
- Object
- Rumale::EvaluationMeasure::NormalizedMutualInformation
- Includes:
- Base::Evaluator
- Defined in:
- rumale-evaluation_measure/lib/rumale/evaluation_measure/normalized_mutual_information.rb
Overview
NormalizedMutualInformation is a class that calculates the normalized mutual information.
Reference
-
Manning, C D., Raghavan, P., and Schutze, H., “Introduction to Information Retrieval,” Cambridge University Press., 2008.
-
Vinh, N X., Epps, J., and Bailey, J., “Information Theoretic Measures for Clusterings Comparison: Variants, Properties, Normalization and Correction for Chance,” J. Machine Learning Research, vol. 11, pp. 2837–1854, 2010.
Instance Method Summary collapse
-
#score(y_true, y_pred) ⇒ Float
Calculate noramlzied mutual information.
Instance Method Details
#score(y_true, y_pred) ⇒ Float
Calculate noramlzied mutual information
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'rumale-evaluation_measure/lib/rumale/evaluation_measure/normalized_mutual_information.rb', line 27 def score(y_true, y_pred) # calculate entropies. class_entropy = entropy(y_true) return 0.0 if class_entropy.zero? cluster_entropy = entropy(y_pred) return 0.0 if cluster_entropy.zero? # calculate mutual information. mi = MutualInformation.new mi.score(y_true, y_pred) / Math.sqrt(class_entropy * cluster_entropy) end |