在spaCy中繪制PR曲線可以使用以下步驟:
pip install spacy scikit-learn matplotlib
import spacy
from sklearn.metrics import precision_recall_curve
import matplotlib.pyplot as plt
nlp = spacy.load("en_core_web_sm")
texts = ["Some text", "Another text"]
true_labels = [True, False]
predictions = [nlp(text).cats["LABEL"] > 0.5 for text in texts]
precision_recall_curve
函數計算PR曲線的精確度和召回率:precision, recall, _ = precision_recall_curve(true_labels, predictions)
plt.plot(recall, precision, marker='.')
plt.xlabel('Recall')
plt.ylabel('Precision')
plt.title('Precision-Recall curve')
plt.show()
這樣就可以在spaCy中繪制PR曲線了。記得根據你的實際情況調整代碼中的數據和參數。