(self)
return clusters[0]
Return the best cluster from this collection.
Return the best cluster from this collection.
Return the best cluster from this collection .
def best_cluster(self):
        """Return the best cluster from this collection."""
        if len(self) <= 1:
            return self

        # Group by region code
        clusters = defaultdict(list)
        for result in self:
            clusters[result.region_code].append(result)

        def sum_score(values):
            # Sort by highest cumulative score,
            # break tie by region with the largest radius.
            return (sum([v.score for v in values]), max([v.accuracy for v in values]))

        clusters = sorted(clusters.values(), key=sum_score, reverse=True)
        return clusters[0]
def best_cluster ( self ) : if len ( self ) <= 1 : return self # Group by region code clusters = defaultdict ( list ) for result in self : clusters [ result . region_code ] . append ( result ) def sum_score ( values ) : # Sort by highest cumulative score, # break tie by region with the largest radius. return ( sum ( [ v . score for v in values ] ) , max ( [ v . accuracy for v in values ] ) ) clusters = sorted ( clusters . values ( ) , key = sum_score , reverse = True ) return clusters [ 0 ]