Area under the ROC curve
483886
def auc(y_true, y_pred, round=True):
    
    y_true, y_pred = _mask_value_nan(y_true, y_pred)

    if round:
        y_true = y_true.round()
    if len(y_true) == 0 or len(np.unique(y_true)) < 2:
        return np.nan
    return skm.roc_auc_score(y_true, y_pred)
960952
def score(self, i):
        """"""
        if self.minimize:
            return self.data[i][0]
        else:
            return self.data[(-1 * i) - 1][0]
605228
def roc_auc_cv(self,features,labels):
        """"""        
        if callable(getattr(self.ml, "decision_function", None)):
            return np.mean([self.scoring_function(labels[test],
                            self.pipeline.fit(features[train],labels[train]).
                                         decision_function(features[test]))
                            for train, test in KFold().split(features, labels)])
        elif callable(getattr(self.ml, "predict_proba", None)):
            return np.mean([self.scoring_function(labels[test],
                            self.pipeline.fit(features[train],labels[train]).
                                            predict_proba(features[test])[:,1])
                            for train, test in KFold().split(features, labels)]) 
        else:
            raise ValueError("ROC AUC score won't work with " + self.ml_type + ". No "
                    "decision_function or predict_proba method found for this learner.")
1041804
function findClosest(c) {

    if (colorTab === null) return -1;
    var r = (c & 0xFF0000) >> 16;
    var g = (c & 0x00FF00) >> 8;
    var b = (c & 0x0000FF);
    var minpos = 0;
    var dmin = 256 * 256 * 256;
    var len = colorTab.length;

    for (var i = 0; i < len;) {
      var dr = r - (colorTab[i++] & 0xff);
      var dg = g - (colorTab[i++] & 0xff);
      var db = b - (colorTab[i] & 0xff);
      var d = dr * dr + dg * dg + db * db;
      var index = i / 3;
      if (usedEntry[index] && (d < dmin)) {
        dmin = d;
        minpos = index;
      }
      i++;
    }
    return minpos;
  }
830038
private void detectCandidateFeatures(T image, double sigma) {
		// adjust corner intensity threshold based upon the current scale factor
		float scaleThreshold = (float) (baseThreshold / Math.pow(sigma, scalePower));
		detector.setThreshold(scaleThreshold);
		computeDerivative.setInput(image);

		D derivX = null, derivY = null;
		D derivXX = null, derivYY = null, derivXY = null;

		if (detector.getRequiresGradient()) {
			derivX = computeDerivative.getDerivative(true);
			derivY = computeDerivative.getDerivative(false);
		}
		if (detector.getRequiresHessian()) {
			derivXX = computeDerivative.getDerivative(true, true);
			derivYY = computeDerivative.getDerivative(false, false);
			derivXY = computeDerivative.getDerivative(true, false);
		}

		detector.process(image, derivX, derivY, derivXX, derivYY, derivXY);

		intensities[spaceIndex].reshape(image.width, image.height);
		intensities[spaceIndex].setTo(detector.getIntensity());

		List<Point2D_I16> m = maximums[spaceIndex];
		m.clear();
		QueueCorner q = detector.getMaximums();
		for (int i = 0; i < q.size; i++) {
			m.add(q.get(i).copy());
		}

		spaceIndex++;
		if (spaceIndex >= 3)
			spaceIndex = 0;
	}
1062632
def _outliers(self,x):
        
        outliers = self._tukey(x, threshold = 1.5)
        return np.size(outliers)
687079
def _dK_dR(self, R):
        """"""
        return -self._ns * self._N / R**2 / self._sin_alpha
250849
function area(p, q, r) {
       return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
   }
1295626
def evaluate_accuracy(data_iterator, net):
    """"""
    acc = mx.metric.Accuracy()
    for data, label in data_iterator:
        output = net(data)
        predictions = nd.argmax(output, axis=1)
        predictions = predictions.reshape((-1, 1))
        acc.update(preds=predictions, labels=label)
    return acc.get()[1]
696016
function ccw(c) {
    var n = c.length
    var area = [0]
    for(var j=0; j<n; ++j) {
      var a = positions[c[j]]
      var b = positions[c[(j+1)%n]]
      var t00 = twoProduct(-a[0], a[1])
      var t01 = twoProduct(-a[0], b[1])
      var t10 = twoProduct( b[0], a[1])
      var t11 = twoProduct( b[0], b[1])
      area = robustSum(area, robustSum(robustSum(t00, t01), robustSum(t10, t11)))
    }
    return area[area.length-1] > 0
  }
729559
def threshold(image, block_size=DEFAULT_BLOCKSIZE, mask=None):
    
    if mask is None:
        mask = np.zeros(image.shape[:2], dtype=np.uint8)
        mask[:] = 255

    if len(image.shape) > 2 and image.shape[2] == 4:
        image = cv2.cvtColor(image, cv2.COLOR_BGRA2GRAY)
    res = _calc_block_mean_variance(image, mask, block_size)
    res = image.astype(np.float32) - res.astype(np.float32) + 255
    _, res = cv2.threshold(res, 215, 255, cv2.THRESH_BINARY)
    return res
1163565
def _estimate_delta(ntriangles, area):
    
    return np.sqrt(4./np.sqrt(3) * float(area) / float(ntriangles))
1313588
def score(self, testing_features, testing_labels):
        """"""
        # print("test features shape:",testing_features.shape)
        # print("testing labels shape:",testing_labels.shape)
        yhat = self.predict(testing_features)
        return self.scoring_function(testing_labels,yhat)
1058246
def get_roc_values(motif, fg_file, bg_file):
    """"""
    #print(calc_stats(motif, fg_file, bg_file, stats=["roc_values"], ncpus=1))
    #["roc_values"])
    
    try:
#        fg_result = motif.pwm_scan_score(Fasta(fg_file), cutoff=0.0, nreport=1)
#        fg_vals = [sorted(x)[-1] for x in fg_result.values()]
#
#        bg_result = motif.pwm_scan_score(Fasta(bg_file), cutoff=0.0, nreport=1)
#        bg_vals = [sorted(x)[-1] for x in bg_result.values()]

#        (x, y) = roc_values(fg_vals, bg_vals)
        stats = calc_stats(motif, fg_file, bg_file, stats=["roc_values"], ncpus=1)
        (x,y) = list(stats.values())[0]["roc_values"]
        return None,x,y
    except Exception as e:
        print(motif)
        print(motif.id)
        raise
        error = e
        return error,[],[]
756477
def keep_absolute_impute__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
    
    return __run_measure(measures.keep_mask, X, y, model_generator, method_name, 0, num_fcounts, sklearn.metrics.roc_auc_score)
328378
private void computeContainment( int imageArea ) {
		// mark that the track is in the inlier set and compute the containment rectangle
		contRect.x0 = contRect.y0 = Double.MAX_VALUE;
		contRect.x1 = contRect.y1 = -Double.MAX_VALUE;
		for( AssociatedPair p : motion.getModelMatcher().getMatchSet() ) {
			Point2D_F64 t = p.p2;
			if( t.x > contRect.x1 )
				contRect.x1 = t.x;
			if( t.y > contRect.y1 )
				contRect.y1 = t.y;
			if( t.x < contRect.x0 )
				contRect.x0 = t.x;
			if( t.y < contRect.y0 )
				contRect.y0 = t.y;
		}
		containment = contRect.area()/imageArea;
	}
305236
def area(self):
        """"""
        area = self.parse['attributes'].get('Shape_Area')
        if area:
            return round(float(area) * 10.76391)