Ingat di k Hitung ular piton
def precision(actual, predicted, k):
act_set = set(actual)
pred_set = set(predicted[:k])
result = len(act_set & pred_set) / float(k)
return result
def recall(actual, predicted, k):
act_set = set(actual)
pred_set = set(predicted[:k])
result = len(act_set & pred_set) / float(len(act_set))
return result
Naughty Nightingale