我正在尝试使用spaCy训练一个基本的文本分类模型。我有一组文本,并想构建一个模型,将每个文本分类为outcome1
或outcome2
。假设我的数据如下:
texts = ["This is the first example text",
"This is the second example text",
"This is yet another text"]
y = ["outcome2", "outcome1", "outcome1"]
我的问题是,我甚至不能将这些文本处理成文档:
nlp = spacy.blank("en")
textcat = nlp.create_pipe("textcat")
textcat.add_label("outcome1")
textcat.add_label("outcome2")
textcat = nlp.add_pipe("textcat", last = True)
nlp.pipe_names
>>> ['textcat']
但是当我尝试处理任何文本时,会出现错误:
doc = nlp("This is a sentence")
>>> ValueError: Cannot get dimension 'nO' for model 'sparse_linear': value unset
我尝试跟着这个教程(有点过时)(链接),使用 spaCy 快速入门小部件 设立一个项目,但是在初始化配置文件时一直遇到错误。我错过了什么吗?