我使用这个官方示例代码使用我自己的训练样本从头开始训练一个 NER 模型。
当我在新文本上使用此模型进行预测时,我想获得每个实体的预测概率。
Run Code Online (Sandbox Code Playgroud)# test the saved model print("Loading from", output_dir) nlp2 = spacy.load(output_dir) for text, _ in TRAIN_DATA: doc = nlp2(text) print("Entities", [(ent.text, ent.label_) for ent in doc.ents]) print("Tokens", [(t.text, t.ent_type_, t.ent_iob) for t in doc])
我无法在 Spacy 中找到一种方法来获得每个实体的预测概率。
我如何从 Spacy 获得这个概率?我需要它来应用截止。