Python scipy.stats.stats.spearmanr() Examples
The following are 4
code examples of scipy.stats.stats.spearmanr().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
scipy.stats.stats
, or try the search function
.
Example #1
Source File: metrics.py From OpenKiwi with GNU Affero General Public License v3.0 | 5 votes |
def summarize(self): spearman = spearmanr(self.predictions, self.target)[0] summary = {self.metric_name: spearman} return self._prefix_keys(summary)
Example #2
Source File: evaluate.py From OpenKiwi with GNU Affero General Public License v3.0 | 5 votes |
def score_sentence_level(gold, pred): pearson = pearsonr(gold, pred) mae = mean_absolute_error(gold, pred) rmse = np.sqrt(mean_squared_error(gold, pred)) spearman = spearmanr( rankdata(gold, method="ordinal"), rankdata(pred, method="ordinal") ) delta_avg = delta_average(gold, rankdata(pred, method="ordinal")) return (pearson[0], mae, rmse), (spearman[0], delta_avg)
Example #3
Source File: similarity.py From vecto with Mozilla Public License 2.0 | 5 votes |
def evaluate(self, embs, data): details = [] results = [] cnt_found_pairs_total = 0 for (x, y), sim in data: x = x.lower() y = y.lower() # print(x,y) if embs.has_word(x) and embs.has_word(y) and not math.isnan(embs.get_vector(x).dot(embs.get_vector(y))): # print(m.get_row(x).dot(m.get_row(y))) v = embs.get_vector(x).dot(embs.get_vector(y)) results.append((v, sim)) cnt_found_pairs_total += 1 details.append([x, y, float(v), float(sim)]) else: if not self.ignore_oov: # results.append((-1, sim)) # details.append([x, y, str(-1), str(sim)]) results.append((0, sim)) details.append([x, y, str(0), str(sim)]) # print('oov') pass if len(results) <= 2: return -1, cnt_found_pairs_total, [] actual, expected = zip(*results) # print(actual) return spearmanr(actual, expected)[0], cnt_found_pairs_total, details
Example #4
Source File: qe_model.py From qebrain with BSD 2-Clause "Simplified" License | 5 votes |
def _spearman(grt_file, pre_file): pre = np.loadtxt(pre_file) grt = np.loadtxt(grt_file) return spearmanr(pre, grt).correlation