Calculates the pair of metrics for each threshold for each result.
322223
def build_report(self):
        
        thresholds = self.thresholds
        lower_quantile = self.config['lower_quantile']
        upper_quantile = self.config['upper_quantile']

        if self.n_current_results > self.n_cached_curves:
            # If there are new curves, recompute
            colnames = ['_'.join([metric, stat])
                        for metric in [self.metric1.name, self.metric2.name]
                        for stat in ['Mean', 'Median',
                                     '%d_Percentile' % (100*lower_quantile),
                                     '%d_Percentile' % (upper_quantile*100)]]
            self.ret = pd.DataFrame(columns=colnames, index=thresholds, dtype='float64')

            for threshold in thresholds:
                m1s = Series([self.metric1.score(result, threshold) for result in self.results])
                m2s = Series([self.metric2.score(result, threshold) for result in self.results])
                self.ret.loc[threshold] = (m1s.mean(), m1s.quantile(.5), m1s.quantile(.05), m1s.quantile(.95),
                                           m2s.mean(), m2s.quantile(.5), m2s.quantile(.05), m2s.quantile(.95))
        self.build_curves()
        self.summary_df = self.ret
        return self.ret
1015803
private List<double[]> calculateStdMeasurementsForParam(
            int            numEntriesPerPreview,
            int            numParamValues,
            int            paramValue,
            List<double[]> meanParamMeasurements)
    {
        List<double[]> paramMeasurementsSquaredDiffSum = 
                new ArrayList<double[]>(numEntriesPerPreview);
        List<double[]> paramMeasurementsStd            = 
                new ArrayList<double[]>(numEntriesPerPreview);
        
        int numCompleteFolds = 0;
        
        // sum up squared differences between measurements and mean values
        for (PreviewCollection<Preview> foldPreview : 
             this.origMultiRunPreviews.subPreviews) 
        {
            // check if there is a preview for each parameter value
            if (foldPreview.getPreviews().size() == numParamValues) {
                numCompleteFolds++;
                
                Preview foldParamPreview = 
                        foldPreview.getPreviews().get(paramValue);
                
                // add this Preview's standardDeviations to the overall sum
                this.addPreviewMeasurementSquaredDiffsToSum(
                        meanParamMeasurements, 
                        paramMeasurementsSquaredDiffSum,
                        foldParamPreview, 
                        numEntriesPerPreview);
            }
        }
        
        // divide sum by number of folds and take square root 
        for (int entryIdx = 0; entryIdx < numEntriesPerPreview; entryIdx++) {
            double[] sumEntry = paramMeasurementsSquaredDiffSum.get(entryIdx);
            double[] stdEntry = new double[sumEntry.length];
            
            // first measurement is used for indexing -> simply copy
            stdEntry[0] = sumEntry[0];
            
            // calculate standard deviation for remaining measurements
            for (int m = 1; m < sumEntry.length; m++) {
                if (numCompleteFolds > 1) {
                    stdEntry[m] = Math.sqrt(sumEntry[m]/(numCompleteFolds-1));
                }
                else {
                    stdEntry[m] = Math.sqrt(sumEntry[m]);
                }
            }
            
            paramMeasurementsStd.add(stdEntry);
        }
        
        return paramMeasurementsStd;
    }
829712
def results_overall_metrics(self):
        

        if self.overall['Nsys'] != 0:
            accuracy = self.overall['Ncorr'] / float(self.overall['Nsys'])
        else:
            accuracy = None

        return {
            'count': self.overall,
            'accuracy': accuracy
        }
729145
def _get_cumulative_results(self, results):
        
        hits = {'total': 0, 'unique': 0}

        day_hits = list(hits[0] for hits in results.values() if hits)
        for metrics in day_hits:
            hits['total'] += metrics['nb_hits']
            hits['unique'] += metrics['nb_uniq_visitors']

        return hits
1284017
public void applyFeatureCountThreshold(List<Pair<Pattern, Integer>> thresholds) {

    // get feature counts
    float[] counts = getFeatureCounts();

    // build a new featureIndex
    Index<F> newFeatureIndex = new HashIndex<F>();
    LOOP: for (F f : featureIndex) {
      for (Pair<Pattern, Integer> threshold : thresholds) {
        Pattern p = threshold.first();
        Matcher m = p.matcher(f.toString());
        if (m.matches()) {
          if (counts[featureIndex.indexOf(f)] >= threshold.second) {
            newFeatureIndex.add(f);
          }
          continue LOOP;
        }
      }
      // we only get here if it didn't match anything on the list
      newFeatureIndex.add(f);
    }

    counts = null;

    int[] featMap = new int[featureIndex.size()];
    for (int i = 0; i < featMap.length; i++) {
      featMap[i] = newFeatureIndex.indexOf(featureIndex.get(i));
    }

    featureIndex = null;

    for (int i = 0; i < size; i++) {
      List<Integer> featList = new ArrayList<Integer>(data[i].length);
      for (int j = 0; j < data[i].length; j++) {
        if (featMap[data[i][j]] >= 0) {
          featList.add(featMap[data[i][j]]);
        }
      }
      data[i] = new int[featList.size()];
      for (int j = 0; j < data[i].length; j++) {
        data[i][j] = featList.get(j);
      }
    }

    //TODO: continuation of hack from above... hope those features are really strings
    //if you call this function. ~Sarah
    featureIndex = newFeatureIndex;
  }
644462
def fit(self, weighted, show_progress=True):
        
        self.similarity = all_pairs_knn(weighted, self.K,
                                        show_progress=show_progress,
                                        num_threads=self.num_threads).tocsr()
        self.scorer = NearestNeighboursScorer(self.similarity)
929420
public static MetricInfo computeAllMetrics() {
        long start = System.currentTimeMillis();
        MetricInfo metricInfo = MetricUtils.mkMetricInfo();

        List<Map.Entry<String, AsmMetric>> entries = Lists.newLinkedList();
        if (enableStreamMetrics) {
            entries.addAll(streamMetrics.metrics.entrySet());
        }
        entries.addAll(taskMetrics.metrics.entrySet());
        entries.addAll(componentMetrics.metrics.entrySet());
        entries.addAll(compStreamMetrics.metrics.entrySet());
        entries.addAll(workerMetrics.metrics.entrySet());
        entries.addAll(nettyMetrics.metrics.entrySet());
        entries.addAll(topologyMetrics.metrics.entrySet());

        for (Map.Entry<String, AsmMetric> entry : entries) {
            String name = entry.getKey();
            AsmMetric metric = entry.getValue();

            // skip disabled metrics, double check
            if (disabledMetricNames.contains(metric.getShortName())) {
                continue;
            }
            Map<Integer, AsmSnapshot> snapshots = metric.getSnapshots();
            if (snapshots.size() == 0) {
                continue;
            }

            int op = metric.getOp();
            if ((op & AsmMetric.MetricOp.LOG) == AsmMetric.MetricOp.LOG) {
                MetricUtils.printMetricSnapshot(metric, snapshots);
            }

            if ((op & AsmMetric.MetricOp.REPORT) == AsmMetric.MetricOp.REPORT) {
                MetaType metaType = MetricUtils.metaType(metric.getMetricName());
                try {
                    if (metric instanceof AsmCounter) {
                        Map data = MetricUtils.toThriftCounterSnapshots(snapshots);
                        putIfNotEmpty(metricInfo.get_metrics(), name, data);
                    } else if (metric instanceof AsmGauge) {
                        Map data = MetricUtils.toThriftGaugeSnapshots(snapshots);
                        putIfNotEmpty(metricInfo.get_metrics(), name, data);
                    } else if (metric instanceof AsmMeter) {
                        Map data = MetricUtils.toThriftMeterSnapshots(snapshots);
                        putIfNotEmpty(metricInfo.get_metrics(), name, data);
                    } else if (metric instanceof AsmHistogram) {
                        Map data = MetricUtils.toThriftHistoSnapshots(metaType, snapshots);
                        putIfNotEmpty(metricInfo.get_metrics(), name, data);
                    }
                } catch (Exception ex) {
                    LOG.error("Error", ex);
                }
            }
        }

        if (debug) {
            MetricUtils.printMetricInfo(metricInfo, debugMetricNames);
        }
        LOG.debug("compute all metrics, cost:{}", System.currentTimeMillis() - start);
        return metricInfo;
    }
1124513
def compute_file_metrics(processors, language, key, token_list):
    """"""
    # multiply iterator
    tli = itertools.tee(token_list, len(processors))
    metrics = OrderedDict()

    # reset all processors
    for p in processors:
        p.reset()

    # process all tokens
    for p, tl in zip(processors, tli):
        p.process_file(language, key, tl)

    # collect metrics from all processors
    for p in processors:
        metrics.update(p.metrics)

    return metrics
409014
function combineStatsAndIndexes(done, results) {
  var indexes = results.getIndexes;
  var stats = results.getIndexStats;
  var sizes = results.getIndexSizes;
  _.each(indexes, function(idx, i) {
    _.assign(indexes[i], stats[idx.name]);
    _.assign(indexes[i], sizes[idx.name]);
  });
  done(null, indexes);
}
289781
def get_thresholds(points=100, power=3) -> list:
    """"""
    return [(i / (points + 1)) ** power for i in range(1, points + 1)]
183294
function getThreshold(threshold) {
			if (min > threshold) {
				threshold = min;
			} else if (max < threshold) {
				threshold = max;
			}

			return translate(threshold, 0, 1);
		}
1074154
def is_correlated(self, threshold=0):
        
        return self.correlation_result if self.correlation_result.coefficient >= threshold else False
363569
def process_results(results):
    
    raw_results = results[0]
    processing_result = 0
    for each_qubit_measurement in raw_results:
        processing_result = 2*processing_result + each_qubit_measurement
    # Convert from 0 indexed to 1 indexed
    die_value = processing_result + 1
    return die_value
1080195
public void calcScore()
  {

    if ((getPredicateCount() > 0) || (null != m_relativePathPattern))
    {
      m_score = SCORE_OTHER;
    }
    else
      super.calcScore();

    if (null == m_targetString)
      calcTargetString();
  }
39393
private void processQualityViolationsScore(
    QualityScoreSettings.ViolationsScoreSettings qualityViolationsSettings,
    Iterable<CodeQuality> codeQualityIterable,
    List<ScoreWeight> categoryScores) {
    ScoreWeight qualityViolationsScore = getCategoryScoreByIdName(categoryScores, WIDGET_QUALITY_VIOLATIONS_ID_NAME);
    Double qualityBlockerRatio = fetchQualityValue(codeQualityIterable, QUALITY_PARAM_BLOCKER_VIOLATIONS);
    Double qualityCriticalRatio = fetchQualityValue(codeQualityIterable, QUALITY_PARAM_CRITICAL_VIOLATIONS);
    Double qualityMajorRatio = fetchQualityValue(codeQualityIterable, QUALITY_PARAM_MAJOR_VIOLATIONS);

    if (null == qualityBlockerRatio && null == qualityCriticalRatio && null == qualityMajorRatio) {
      qualityViolationsScore.setScore(
        qualityViolationsSettings.getCriteria().getNoDataFound()
      );
      qualityViolationsScore.setMessage(Constants.SCORE_ERROR_NO_DATA_FOUND);
      qualityViolationsScore.setState(ScoreWeight.ProcessingState.criteria_failed);
    } else {
      try {
        //Violation score is calculated based on weight for each type
        // Blocker
        // Critical
        // Major
        Double violationScore = Double.valueOf(Constants.MAX_SCORE) - (
            getViolationScore(qualityBlockerRatio, qualityViolationsSettings.getBlockerViolationsWeight()) +
            getViolationScore(qualityCriticalRatio, qualityViolationsSettings.getCriticalViolationsWeight()) +
            getViolationScore(qualityMajorRatio, qualityViolationsSettings.getMajorViolationWeight())
          );

        if (!qualityViolationsSettings.isAllowNegative() && violationScore.compareTo(Constants.ZERO_SCORE) < 0) {
          violationScore = Constants.ZERO_SCORE;
        }

        //Check thresholds at widget level
        checkPercentThresholds(qualityViolationsSettings, violationScore);
        qualityViolationsScore.setScore(
          new ScoreTypeValue(violationScore)
        );
        qualityViolationsScore.setState(ScoreWeight.ProcessingState.complete);
      } catch (ThresholdException ex) {
        setThresholdFailureWeight(ex, qualityViolationsScore);
      }
    }
  }
847723
function analizeScores(thresholds, categoryReport) {
  for (const category in categoryReport) {
    if (!Object.prototype.hasOwnProperty.call(thresholds, category)) {
      continue;
    }

    if (Number(categoryReport[category]) < Number(thresholds[category])) {
      return false;
    }
  }

  return true;
}
484672
private SeedInfo score( View target ) {
		SeedInfo output = new SeedInfo();
		output.seed = target;
		scoresMotions.reset();

		// score all edges
		for (int i = 0; i < target.connections.size; i++) {
			PairwiseImageGraph2.Motion m = target.connections.get(i);
			if( !m.is3D )
				continue;

			scoresMotions.grow().set(score(m),i);
		}

		// only score the 3 best. This is to avoid biasing it for
		Collections.sort(scoresMotions.toList());

		for (int i = Math.min(2, scoresMotions.size); i >= 0; i--) {
			output.motions.add(scoresMotions.get(i).index);
			output.score += scoresMotions.get(i).score;
		}

		return output;
	}