beta = $beta; } /** * Return a tuple of the min and max output value for this metric. * * @return \Rubix\ML\Tuple{float,float} */ public function range() : Tuple { return new Tuple(0.0, 1.0); } /** * The estimator types that this metric is compatible with. * * @internal * * @return list */ public function compatibility() : array { return [ EstimatorType::clusterer(), ]; } /** * Score a set of predictions. * * @param list $predictions * @param list $labels * @return float */ public function score(array $predictions, array $labels) : float { $homogeneity = (new Homogeneity())->score($predictions, $labels); $completeness = (new Completeness())->score($predictions, $labels); return (1.0 + $this->beta) * $homogeneity * $completeness / (($this->beta * $homogeneity + $completeness) ?: EPSILON); } /** * Return the string representation of the object. * * @internal * * @return string */ public function __toString() : string { return "V Measure (beta: {$this->beta})"; } }