return confidence based on existing data
165704
def get_confidence(self):
        """"""
        # if we didn't receive any character in our consideration range,
        # return negative answer
        if self._total_chars <= 0 or self._freq_chars <= self.MINIMUM_DATA_THRESHOLD:
            return self.SURE_NO

        if self._total_chars != self._freq_chars:
            r = (self._freq_chars / ((self._total_chars - self._freq_chars)
                 * self.typical_distribution_ratio))
            if r < self.SURE_YES:
                return r

        # normalize confidence (we don't want to be 100% sure)
        return self.SURE_YES
331303
def compute_absolute_error(self, predicted_data, record, dataframe_record):
        ''''''
        absolute_error = abs(record['DDG'] - predicted_data[self.ddg_analysis_type])
        dataframe_record['AbsoluteError'] = absolute_error
599741
def compare_data(self, data):
        '''
        
        '''
        if self.old_data != data:
            self.old_data = data
            return True
        return False
781402
def confidence_interval_survival_function_(self):
        
        return self._compute_confidence_bounds_of_transform(self._survival_function, self.alpha, self._ci_labels)
1134808
public static function CONFIDENCE($alpha, $stdDev, $size)
    {
        $alpha  = PHPExcel_Calculation_Functions::flattenSingleValue($alpha);
        $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev);
        $size   = floor(PHPExcel_Calculation_Functions::flattenSingleValue($size));

        if ((is_numeric($alpha)) && (is_numeric($stdDev)) && (is_numeric($size))) {
            if (($alpha <= 0) || ($alpha >= 1)) {
                return PHPExcel_Calculation_Functions::NaN();
            }
            if (($stdDev <= 0) || ($size < 1)) {
                return PHPExcel_Calculation_Functions::NaN();
            }
            return self::NORMSINV(1 - $alpha / 2) * $stdDev / sqrt($size);
        }
        return PHPExcel_Calculation_Functions::VALUE();
    }
870524
def detect(filename, include_confidence=False):
    
    f = open(filename)
    detection = chardet.detect(f.read())
    f.close()
    encoding = detection.get('encoding')
    confidence = detection.get('confidence')
    if include_confidence:
        return (encoding, confidence)
    return encoding
86983
def _check_constant_value_data(self, data):
        """"""

        arrayval = data.flat[0]
        if np.all(data == arrayval):
            return arrayval
        return None
744517
def fit(self, X, y):
        """"""

        self._data = X
        self._classes = np.unique(y)
        self._labels = y
        self._is_fitted = True
716843
def get_error(data, labels, pos_neurons, neg_neurons = [], add_noise = True):
  
  num_correct = 0
  num_false_positives = 0
  num_false_negatives = 0
  classifications = numpy.zeros(data.nRows())
  for neuron in pos_neurons:
    classifications += neuron.calculate_on_entire_dataset(data)
  for neuron in neg_neurons:
    classifications -= neuron.calculate_on_entire_dataset(data)
  if add_noise:
    classifications += (numpy.random.rand() - 0.5)/1000
  classifications = numpy.sign(classifications)
  for classification, label in zip(classifications, labels):
    if classification > 0 and label > 0:
      num_correct += 1.0
    elif classification <= 0 and label <= 0:
      num_correct += 1.0
    elif classification > 0 and label <= 0:
      num_false_positives += 1
    else:
      num_false_negatives += 1
  return (1.*num_false_positives + num_false_negatives)/data.nRows(), num_false_positives, num_false_negatives
1081197
def compute_mu_star_confidence(ee, num_trajectories, num_resamples,
                               conf_level):
    '''
    
    '''
    ee_resampled = np.zeros([num_trajectories])
    mu_star_resampled = np.zeros([num_resamples])

    if not 0 < conf_level < 1:
        raise ValueError("Confidence level must be between 0-1.")

    resample_index = np.random.randint(
        len(ee), size=(num_resamples, num_trajectories))
    ee_resampled = ee[resample_index]
    # Compute average of the absolute values over each of the resamples
    mu_star_resampled = np.average(np.abs(ee_resampled), axis=1)

    return norm.ppf(0.5 + conf_level / 2) * mu_star_resampled.std(ddof=1)
868010
def process_results(self, results=None, **value):
        """"""
        for res in results:
            if 'mask' in res:
                res['mask'] = utils.IrcString(res['mask'])
            value['success'] = res.pop('retcode', None) != '486'
            value.update(res)
        return value
920995
def Likelihood(self, data, hypo):
        
        mix = self.loci[hypo]
        like = mix[data]
        return like
499964
def get_accuracy(query, gff_file, evidences_bed, sizesfile, type, key):
    
    from jcvi.formats.bed import evaluate

    bed_file = get_bed_file(gff_file, type, key)
    b = evaluate([bed_file, evidences_bed, sizesfile, "--query={0}".format(query)])

    return b
238357
def _extract_return(self, data):
        '''
        
        '''
        if isinstance(data, dict):
            data = data.get('return', data)

        return data
819863
def _return_result(self, result, comparison_vectors=None):
        
        return_type = cf.get_option('classification.return_type')

        if type(result) != np.ndarray:
            raise ValueError("numpy.ndarray expected.")

        # return the pandas.MultiIndex
        if return_type == 'index':
            return comparison_vectors.index[result.astype(bool)]

        # return a pandas.Series
        elif return_type == 'series':
            return pandas.Series(
                result,
                index=comparison_vectors.index,
                name='classification')

        # return a numpy.ndarray
        elif return_type == 'array':
            return result

        # return_type not known
        else:
            raise ValueError(
                "return_type {} unknown. Choose 'index', 'series' or "
                "'array'".format(return_type))
1085094
def _guess_x_simple(self, y_desired, y_dims=None, **kwargs):
        """"""
        _, indexes = self.fmodel.dataset.nn_y(y_desired, dims=y_dims, k = 10)
        return [self.fmodel.get_x(i) for i in indexes]
810253
def accuracy(y, z):
    
    tp, tn, fp, fn = contingency_table(y, z)
    return (tp + tn) / (tp + tn + fp + fn)