Return the classification error rate
345471
def class_error(self, input_data, targets, average=True,
                    cache=None, prediction=False):
        

        if cache is not None:
            activations = cache
        else:
            activations = \
              self.feed_forward(input_data, prediction=prediction)

        targets = targets.get().argmax(1)
        class_error = np.sum(activations.get().argmax(1) != targets)

        if average: class_error = float(class_error) / targets.shape[0]
        return class_error
452480
def get_CV_accuracy(self):
        
        accuracy = {}
        for fold, train, test in self._kf:
            acc = self._cv_model[fold].get_accuracy()
            accuracy[fold] = acc["test_acc_final"]
        return accuracy
880242
def _std_err(self):
        
        return np.sqrt(np.sum(np.square(self._resids), axis=1) / self._df_err)
163776
private double getHistoryErrorRate(List<Integer> predHistory){
		double sumCorrect = 0;
		for (Integer e : predHistory) {
			sumCorrect += e;
		}
		return 1. - (sumCorrect / predHistory.size());
	}
1061697
def get_cv_accuracy(res):
    
    ac_list = [(accuracy["train_acc_final"],
                accuracy["test_acc_final"]
                )
               for accuracy, weights in res]
    ac = np.array(ac_list)

    perf = {
        "mean_train_acc": np.mean(ac[:, 0]),
        "std_train_acc": np.std(ac[:, 0]),
        "mean_test_acc": np.mean(ac[:, 1]),
        "std_test_acc": np.std(ac[:, 1]),

    }
    return perf
1213762
def get_rates(self, mmin, mmax=np.inf):
        
        nsrcs = self.number_sources()
        for iloc, source in enumerate(self.source_model):
            print("Source Number %s of %s, Name = %s, Typology = %s" % (
                iloc + 1,
                nsrcs,
                source.name,
                source.__class__.__name__))
            if isinstance(source, CharacteristicFaultSource):
                self._get_fault_rates(source, mmin, mmax)
            elif isinstance(source, ComplexFaultSource):
                self._get_fault_rates(source, mmin, mmax)
            elif isinstance(source, SimpleFaultSource):
                self._get_fault_rates(source, mmin, mmax)
            elif isinstance(source, AreaSource):
                self._get_area_rates(source, mmin, mmax)
            elif isinstance(source, PointSource):
                self._get_point_rates(source, mmin, mmax)
            else:
                print("Source type %s not recognised - skipping!" % source)
                continue
334686
def get_learning_rate(self, iter):
        '''
        
        '''
        return self.init_lr * ((math.cos(iter * 1.0 / (self.max_iter) * math.pi) + 1.0) * 0.5)
1130583
def ReliefF_compute_scores(inst, attr, nan_entries, num_attributes, mcmap, NN, headers, class_type, X, y, labels_std, data_type):
    
    scores = np.zeros(num_attributes)
    for feature_num in range(num_attributes):
        scores[feature_num] += compute_score(attr, mcmap, NN, feature_num, inst,
                                             nan_entries, headers, class_type, X, y, labels_std, data_type)
    return scores
707870
def error_codes(self):
        
        request_url = "{}/api/0/error_codes".format(self.instance)
        return_value = self._call_api(request_url)
        return return_value
1303063
def calculate_statistics(self):
        ""
        rev_ids = range(0, 100, 1)
        feature_values = zip(rev_ids, [0] * 100)
        scores = [self.score(f) for f in feature_values]
        labels = [s['prediction'] for s in scores]
        statistics = Classification(labels, threshold_ndigits=1, decision_key='probability')
        score_labels = list(zip(scores, labels))
        statistics.fit(score_labels)
        return statistics
1266214
def process_or_validate_classifier_output_features(
        output_features, class_labels, supports_class_scores = True):

    

    def raise_error(msg):

        raise ValueError("Classifier error: %s" % msg)

    class_labels = list(class_labels)

    # First, we need to determine the type of the classes.
    _int_types = _integer_types + (bool, _np.bool_, _np.int32, _np.int64)

    if all(isinstance(cl, _int_types) for cl in class_labels):
        output_class_type = datatypes.Int64()

    elif all(isinstance(cl, _string_types) for cl in class_labels):
        output_class_type = datatypes.String()

    else:
        raise ValueError('Class labels must be all of type int or all of type string.')

    if output_features is None:

        out = [("classLabel", output_class_type)]

        if supports_class_scores:
            out += [("classProbability", datatypes.Dictionary(output_class_type))]

    elif isinstance(output_features, _string_types):

        out = [(output_features, output_class_type)]

        if supports_class_scores:
            out += [("classProbability", datatypes.Dictionary(output_class_type))]

    elif (isinstance(output_features, (list, tuple))
            and all(isinstance(fn, _string_types) for fn in output_features)
            and len(output_features) == 2):

        if supports_class_scores:
            out = [(output_features[0], output_class_type),
                   (output_features[1], datatypes.Dictionary(output_class_type))]
        else:
            raise ValueError("Classifier model (as trained) does not support output scores for classes.")

    elif is_valid_feature_list(output_features):

        output_features = [(k, datatypes._normalize_datatype(dt)) for k, dt in output_features]

        if len(output_features) == 1 or not supports_class_scores:
            if not output_features[0][1] == output_class_type:
                raise ValueError("Type of output class feature does not match type of class labels.")

        else:
            # Make sure the first two output features specified give the output
            # class field and the output class scores dictionary field
            if (isinstance(output_features[0][1], datatypes.Dictionary)
                    and isinstance(output_features[1][1], output_class_type)):

                output_features[0], output_features[1] = output_features[1], output_features[0]

            if not isinstance(output_features[1][1], datatypes.Dictionary):
                raise_error("Output features class scores should be dictionary type.")

            if output_features[1][1].key_type != output_class_type:
                raise_error("Class scores dictionary key type does not match type of class labels.")

            if output_features[0][1] != output_class_type:
                raise_error("Specified type of output class does not match type of class labels.")

        # NOTE: We are intentionally allowing the case where additional fields are allowed
        # beyond the original two features.

        out = output_features

    else:
        raise_error("Form of output features not recognized")

    return out
867923
def get_learning_rate(self, iter):
        '''
        
        '''
        lr = self.scheduler.get_learning_rate(iter)
        if iter < self.warmup_iter:
            lr *= (iter + 1) * 1.0 / self.warmup_iter
        return lr
561736
def get_data_classif(dataset, n, nz=.5, theta=0, random_state=None, **kwargs):
    
    return make_data_classif(dataset, n, nz=.5, theta=0, random_state=None, **kwargs)
698103
def _error_repr(error):
    """"""
    error_repr = repr(error)
    if len(error_repr) > 200:
        error_repr = hash(type(error))
    return error_repr
939985
def evaluate_accuracy(data_iterator, net, ctx, loss_fun, num_classes):
    
    acc = mx.metric.Accuracy()
    loss_avg = 0.
    for i, ((data, length), label) in enumerate(data_iterator):
        data = data.as_in_context(ctx)  # .reshape((-1,784))
        length = length.astype('float32').as_in_context(ctx)
        label = label.as_in_context(ctx)
        output = net(data, length)
        loss = loss_fun(output, label)
        preds = []
        if num_classes == 2:
            preds = (nd.sign(output) + 1) / 2
            preds = preds.reshape(-1)
        else:
            preds = nd.argmax(output, axis=1)
        acc.update(preds=preds, labels=label)
        loss_avg = loss_avg * i / (i + 1) + nd.mean(loss).asscalar() / (i + 1)
    return acc.get()[1], loss_avg
505803
function calculateTotalError(errorMatrix)
{
	var totError = 0.0;
	for(var i = 1; i <= errorMatrix.rows(); i++)
	{
		for(var j = 1; j <= errorMatrix.cols(); j++)
		{
			totError += Math.pow(errorMatrix.e(i, j), 2);
		}
	}
	
	return totError;
}
1255803
def get_error(self, i=None, unit=None,
                  uncover=None, trail=None,
                  linebreak=None, sort_by_indep=None):
        
        return self.get_value(i=i, unit=unit,
                              uncover=uncover, trail=trail,
                              linebreak=linebreak, sort_by_indep=sort_by_indep,
                              attr='_error')