parameters: (self)
return_statement: return clusters[0]
docstring: Return the best cluster from this collection.
docstring_summary: Return the best cluster from this collection.
docstring_tokens: Return the best cluster from this collection .
function: 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]
function_tokens: 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 ]