2 Star 1 Fork 0

glorious years/finalProject

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
fine_tuned.py 945 Bytes
一键复制 编辑 原始数据 按行查看 历史
glorious years 提交于 2024-11-19 18:31 . add fintuning
import torch.nn.functional as F
# new score
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
def calculate_score(generated_report, correct_report):
vectorizer = TfidfVectorizer()
reports = [generated_report, correct_report]
tfidf_matrix = vectorizer.fit_transform(reports)
similarity_score = cosine_similarity(tfidf_matrix[0:1], tfidf_matrix[1:2])[0][0]
return similarity_score
generated_report = "The following is a medical report based on an image: The heart size and pulmonary vascularity appear within normal limits. Lungs are free of focal airspace disease. No pleural effusion or pneumothorax is seen."
correct_report = "The heart size and pulmonary vascularity appear within normal limits. The lungs are free of focal airspace disease. No pleural effusion or pneumothorax is seen."
res = calculate_score(generated_report, correct_report)
print(res)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/lxh_package/final-project.git
[email protected]:lxh_package/final-project.git
lxh_package
final-project
finalProject
master

搜索帮助