本文整理汇总了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