Exemple #1
0
def get_spearman_r(res):
    """
    :param res: results of evaluation, done using learners,
        wrapped into :class:`Orange.evaluation.reliability.Classifier`.
    :type res: :class:`Orange.evaluation.testing.ExperimentResults`

    Return Spearman's coefficient between the prediction error and each of the
    used reliability estimates. Also, return the p-value of each of
    the coefficients.
    """
    prediction_error = get_prediction_error_list(res)
    results = []
    for i in xrange(len(res.results[0].probabilities[0].reliability_estimate)):
        reliability_estimate, signed_or_absolute, method = get_reliability_estimation_list(
            res, i)
        try:
            if signed_or_absolute == SIGNED:
                r, p = statc.spearmanr(prediction_error, reliability_estimate)
            else:
                r, p = statc.spearmanr([abs(pe) for pe in prediction_error],
                                       reliability_estimate)
        except Exception:
            r = p = float("NaN")
        results.append((r, p, signed_or_absolute, method))
    return results
 def __call__(self, e1, e2):
     """
     :param e1: data instances.
     :param e2: data instances.
     
     Returns Sprearman's disimilarity between e1 and e2,
     i.e. (1-r)/2 where r is Sprearman's rank coefficient.
     """
     X1 = []; X2 = []
     for i in self.indxs:
         if not(e1[i].isSpecial() or e2[i].isSpecial()):
             X1.append(float(e1[i]))
             X2.append(float(e2[i]))
     if not X1:
         return 1.0
     try:
         return (1.0 - statc.spearmanr(X1, X2)[0]) / 2.
     except:
         return 1.0
 def __call__(self, e1, e2):
     """
     Return absolute Spearman's dissimilarity between e1 and e2,
     i.e.
      
     .. math:: (1 - abs(r))/2
     
     where r is Spearman's correlation coefficient.
     """
     X1 = []; X2 = []
     for i in self.indxs:
         if not(e1[i].isSpecial() or e2[i].isSpecial()):
             X1.append(float(e1[i]))
             X2.append(float(e2[i]))
     if not X1:
         return 1.0
     try:
         return (1.0 - abs(statc.spearmanr(X1, X2)[0]))
     except:
         return 1.0
Exemple #4
0
 def __call__(self, e1, e2):
     """
     :param e1: data instances.
     :param e2: data instances.
     
     Returns Sprearman's disimilarity between e1 and e2,
     i.e. (1-r)/2 where r is Sprearman's rank coefficient.
     """
     X1 = []
     X2 = []
     for i in self.indxs:
         if not (e1[i].isSpecial() or e2[i].isSpecial()):
             X1.append(float(e1[i]))
             X2.append(float(e2[i]))
     if not X1:
         return 1.0
     try:
         return (1.0 - statc.spearmanr(X1, X2)[0]) / 2.
     except:
         return 1.0
Exemple #5
0
 def __call__(self, e1, e2):
     """
     Return absolute Spearman's dissimilarity between e1 and e2,
     i.e.
      
     .. math:: (1 - abs(r))/2
     
     where r is Spearman's correlation coefficient.
     """
     X1 = []
     X2 = []
     for i in self.indxs:
         if not (e1[i].isSpecial() or e2[i].isSpecial()):
             X1.append(float(e1[i]))
             X2.append(float(e2[i]))
     if not X1:
         return 1.0
     try:
         return (1.0 - abs(statc.spearmanr(X1, X2)[0]))
     except:
         return 1.0