本文整理匯總了Python中scipy.stats.stats.spearmanr方法的典型用法代碼示例。如果您正苦於以下問題:Python stats.spearmanr方法的具體用法?Python stats.spearmanr怎麽用?Python stats.spearmanr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scipy.stats.stats
的用法示例。
在下文中一共展示了stats.spearmanr方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: summarize
# 需要導入模塊: from scipy.stats import stats [as 別名]
# 或者: from scipy.stats.stats import spearmanr [as 別名]
def summarize(self):
spearman = spearmanr(self.predictions, self.target)[0]
summary = {self.metric_name: spearman}
return self._prefix_keys(summary)
示例2: score_sentence_level
# 需要導入模塊: from scipy.stats import stats [as 別名]
# 或者: from scipy.stats.stats import spearmanr [as 別名]
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)
示例3: evaluate
# 需要導入模塊: from scipy.stats import stats [as 別名]
# 或者: from scipy.stats.stats import spearmanr [as 別名]
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
示例4: _spearman
# 需要導入模塊: from scipy.stats import stats [as 別名]
# 或者: from scipy.stats.stats import spearmanr [as 別名]
def _spearman(grt_file, pre_file):
pre = np.loadtxt(pre_file)
grt = np.loadtxt(grt_file)
return spearmanr(pre, grt).correlation