def calculate_f1_score(precision, recall):
# 检查输入是否有效,避免分母为零
if precision == 0 or recall == 0:
return 0.0 # 或者你可以根据需要返回其他值
f1_score = (2 * precision * recall) / (precision + recall)
return f1_score
precision = 0.8939
recall = 0.8946
f1_score = calculate_f1_score(precision, recall)
print("F1 分数为:", f1_score)
07-06
4304
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-27
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-09
3316
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)