def F1(tested, truth):
tested = (tested-0.5)*2
truth = (truth-0.5)*2
truth[truth<=0] = -1.
truth[truth>0] = 1.
res = tested+truth
true_pos = np.size(np.where(res==2))/2.
pos = np.size(np.where(truth ==1))/2.
found_pos = np.size(np.where(tested ==1))/2.
precision = true_pos/found_pos
recall = true_pos/pos
F1 = 2.*precision*recall/(precision+recall)
return F1
# PRE-PROCESSING FUNCTIONS
# TRAINING SET FUNCTIONS
评论列表
文章目录