Spaces:
Runtime error
Runtime error
import evaluate as ev | |
from nDCG import nDCG | |
metric = nDCG(cache_dir="cache") | |
a = [1,2,3,4,5] | |
b = [1,2,3,4,5] | |
c = [1,2,3,4,0] | |
#metric.add(prediction=a, reference=b) | |
metric.add(prediction=c, reference=b) | |
metric.add(prediction=c, reference=b) | |
metric.add(prediction=c, reference=b) | |
print(metric.compute(predictions=[a], references=[b])) | |
print(metric.compute(predictions=[a], references=[c])) | |
print(metric.compute(predictions=[a], references=[c])) | |
print(metric.compute(predictions=[a,a], references=[c,a])) | |
print(metric.cache_file_name) | |
nDCG_metric = ev.load("nDCG.py") | |
results = nDCG_metric.compute(references=[[10, 0, 0, 1, 5]], predictions=[[.1, .2, .3, 4, 70]]) | |
print(results) | |
nDCG_metric = ev.load("nDCG.py") | |
results = nDCG_metric.compute(references=[[10, 0, 0, 1, 5]], predictions=[[.1, .2, .3, 4, 70]], k=3) | |
print(results) | |
nDCG_metric = ev.load("nDCG.py") | |
results = nDCG_metric.compute(references=[[1, 0, 0, 0, 0]], predictions=[[1, 1, 0, 0, 0]], k=1) | |
print(results) | |
results = nDCG_metric.compute(references=[[1, 0, 0, 0, 0]], predictions=[[1, 1, 0, 0, 0]], k=1, ignore_ties=True) | |
print(results) |