Return score from B perspective. If W is winning, score is negative.
979549
def score(self):
        ''
        working_board = np.copy(self.board)
        while EMPTY in working_board:
            unassigned_spaces = np.where(working_board == EMPTY)
            c = unassigned_spaces[0][0], unassigned_spaces[1][0]
            territory, borders = find_reached(working_board, c)
            border_colors = set(working_board[b] for b in borders)
            X_border = BLACK in border_colors
            O_border = WHITE in border_colors
            if X_border and not O_border:
                territory_color = BLACK
            elif O_border and not X_border:
                territory_color = WHITE
            else:
                territory_color = UNKNOWN  # dame, or seki
            place_stones(working_board, territory_color, territory)

        return np.count_nonzero(working_board == BLACK) - np.count_nonzero(working_board == WHITE) - self.komi
418685
def tpr(y_true, y_pred, round=True):
    
    y_true, y_pred = _mask_value_nan(y_true, y_pred)
    if round:
        y_true = np.round(y_true)
        y_pred = np.round(y_pred)
    return skm.recall_score(y_true, y_pred)
968915
def _calculate_split_score(self, split):
        
        left_error = gini(split['left'])
        right_error = gini(split['right'])
        error = gini(self.Y)
        # if the split is any good, the score should be greater than 0
        total = float(len(self.Y))
        score = error - 1 / total * (len(split['left']) * left_error\
                                     + len(split['right']) * right_error)
        return score
444695
def _score(self, state, score_movement=True):
        
        score = 0
        max_score = 0
        if state.total_weight:
            # Coefficient of variance is a value between 0 and the sqrt(n)
            # where n is the length of the series (the number of brokers)
            # so those parameters are scaled by (1 / sqrt(# or brokers)) to
            # get a value between 0 and 1.
            #
            # Since smaller imbalance values are preferred use 1 - x so that
            # higher scores correspond to more balanced states.
            score += self.args.partition_weight_cv_score_weight * \
                (1 - state.broker_weight_cv / sqrt(len(state.brokers)))
            score += self.args.leader_weight_cv_score_weight * \
                (1 - state.broker_leader_weight_cv / sqrt(len(state.brokers)))
            score += self.args.topic_broker_imbalance_score_weight * \
                (1 - state.weighted_topic_broker_imbalance)
            score += self.args.broker_partition_count_score_weight * \
                (1 - state.broker_partition_count_cv / sqrt(len(state.brokers)))
            score += self.args.broker_leader_count_score_weight * \
                (1 - state.broker_leader_count_cv / sqrt(len(state.brokers)))
            max_score += self.args.partition_weight_cv_score_weight
            max_score += self.args.leader_weight_cv_score_weight
            max_score += self.args.topic_broker_imbalance_score_weight
            max_score += self.args.broker_partition_count_score_weight
            max_score += self.args.broker_leader_count_score_weight

        if self.args.max_movement_size is not None and score_movement:
            # Avoid potential divide-by-zero error
            max_movement = max(self.args.max_movement_size, 1)
            score += self.args.movement_size_score_weight * \
                (1 - state.movement_size / max_movement)
            max_score += self.args.movement_size_score_weight

        if self.args.max_leader_changes is not None and score_movement:
            # Avoid potential divide-by-zero error
            max_leader = max(self.args.max_leader_changes, 1)
            score += self.args.leader_change_score_weight * \
                (1 - state.leader_movement_count / max_leader)
            max_score += self.args.leader_change_score_weight

        return score / max_score
772555
function qualityCmp(a, b) {
	if (a.quality === b.quality) {
		return 0;
	} else if (a.quality < b.quality) {
		return 1;
	} else {
		return -1;
	}
}
1238368
def predict_w(self, data3d, voxelsize_mm, weight, label0=0, label1=1):
        
        scores = self.scores(data3d, voxelsize_mm)
        out = scores[label1] > (weight * scores[label0])

        return out
841668
def _score(estimator, X_test, y_test, scorer):
    """"""
    if y_test is None:
        score = scorer(estimator, X_test)
    else:
        score = scorer(estimator, X_test, y_test)
    if not isinstance(score, numbers.Number):
        raise ValueError("scoring must return a number, got %s (%s) instead."
                         % (str(score), type(score)))
    return score
644648
def r2_score_vec(y_true,y_pred):
    

    numerator = (y_true - y_pred) ** 2
    denominator = (y_true - np.average(y_true)) ** 2

    nonzero_denominator = denominator != 0
    nonzero_numerator = numerator != 0
    valid_score = nonzero_denominator & nonzero_numerator
    output_scores = np.ones([y_true.shape[0]])
    output_scores[valid_score] = 1 - (numerator[valid_score] /
                                      denominator[valid_score])
    # arbitrary set to zero to avoid -inf scores, having a constant
    # y_true is not interesting for scoring a regression anyway
    output_scores[nonzero_numerator & ~nonzero_denominator] = 0.

    return output_scores
884514
def f1_score(prediction, ground_truth):
    '''
    
    '''
    prediction_tokens = normalize_answer(prediction).split()
    ground_truth_tokens = normalize_answer(ground_truth).split()
    common = Counter(prediction_tokens) & Counter(ground_truth_tokens)
    num_same = sum(common.values())
    if num_same == 0:
        return 0
    precision = 1.0 * num_same / len(prediction_tokens)
    recall = 1.0 * num_same / len(ground_truth_tokens)
    f1_result = (2 * precision * recall) / (precision + recall)
    return f1_result
926512
def result(self, s, a):
        ''''''
        # result: boat on opposite side, and numbers of missioners and
        # cannibals updated according to the move
        if s[2] == 0:
            return (s[0] - a[1][0], s[1] - a[1][1], 1)
        else:
            return (s[0] + a[1][0], s[1] + a[1][1], 0)
1180601
def objective(self, params):
        """"""
        val = self._penalty * np.sum(params**2)
        for win, los in self._data:
            val += np.logaddexp(0, -(params[win] - params[los]))
        return val
204329
private double score(double betas[]) {
		UtilLepetitEPnP.computeCameraControl(betas,nullPts, solutionPts,numControl);

		int index = 0;
		double score = 0;
		for( int i = 0; i < numControl; i++ ) {
			Point3D_F64 si = solutionPts.get(i);
			Point3D_F64 wi = controlWorldPts.get(i);

			for( int j = i+1; j < numControl; j++ , index++) {
				double ds = si.distance(solutionPts.get(j));
				double dw = wi.distance(controlWorldPts.get(j));

				score += (ds-dw)*(ds-dw);
			}
		}
		return score;
	}
1066862
def _B(self, R):
        """"""
        HNn_R = self._HNn / R

        return HNn_R / self._sin_alpha * (0.4 * HNn_R / self._sin_alpha + 1)
1006316
def rank(self, score):
        '''
        '''
        node = self._head
        rank = 0
        for i in range(self._level-1, -1, -1):
            while node.next[i] and node.next[i].score < score:
                rank += node.width[i]
                node = node.next[i]
        node = node.next[0]
        if node and node.score == score:
            return rank
        else:
            return -2 - rank
609181
def BB(n):
    """"""
    if (n<=1):return Context('0\n1')
    else:
        BB1=BB(n-1)
        AA1=AA(n-1)
        r1 = C1((n-1)*2**(n-2),2**(n-1)) - AA1 - BB1
        r2 = BB1 - C1(2**(n-1),2**(n-1)) - BB1;
        return r1 + r2
139460
def gain_to_loss_ratio(self):
        

        gt = self > 0
        lt = self < 0
        return (nansum(gt) / nansum(lt)) * (self[gt].mean() / self[lt].mean())
555179
def isWon(state, who):
    
    for w in WINS:
        S = sum(1 if (w[k] == 1 and state[k] == who) else 0
                for k in range(ACTIONS))
        if S == 3:
            # We have a win
            return True
    # There were no wins so return False
    return False