code: def thresholdBlocks(self, blocks, recall_weight=1.5):  # pragma: nocover
          
          candidate_records = itertools.chain.from_iterable(self._blockedPairs(blocks))
  
          probability = core.scoreDuplicates(candidate_records,
                                             self.data_model,
                                             self.classifier,
                                             self.num_cores)['score']
  
          probability = probability.copy()
          probability.sort()
          probability = probability[::-1]
  
          expected_dupes = numpy.cumsum(probability)
  
          recall = expected_dupes / expected_dupes[-1]
          precision = expected_dupes / numpy.arange(1, len(expected_dupes) + 1)
  
          score = recall * precision / (recall + recall_weight ** 2 * precision)
  
          i = numpy.argmax(score)
  
          logger.info('Maximum expected recall and precision')
          logger.info('recall: %2.3f', recall[i])
          logger.info('precision: %2.3f', precision[i])
          logger.info('With threshold: %2.3f', probability[i])
  
          return probability[i]
docs: Returns the threshold that maximizes the expected F score, a
          weighted average of precision and recall for a sample of
          blocked data.
  
          Arguments:
  
          blocks -- Sequence of tuples of records, where each tuple is a
                    set of records covered by a blocking predicate
  
          recall_weight -- Sets the tradeoff between precision and
                           recall. I.e. if you care twice as much about
                           recall as you do precision, set recall_weight
                           to 2.