def spearman(self, dataset):
if not isinstance(dataset, list) \
or len(dataset) == 0 \
or len(dataset[0]) != 3 \
or not isinstance(dataset[0][2], float):
raise TypeError('Dataset is not of correct type, list of [str, str, float] triples expected.')
gs_scores, sys_scores = [], []
for one, two, gs_score in dataset:
try:
sys_score = self.sim(one, two)
gs_scores.append(gs_score)
sys_scores.append(sys_score)
except KeyError:
if self.reportMissing:
print('Warning: Missing pair %s-%s - skipping' % (one, two))
continue
return spearmanr(gs_scores, sys_scores)
评论列表
文章目录