我正在尝试使用快速文本 API 构建监督分类器。 我的数据是“output.txt”,包含 15000 行、2 列(性别和姓名)和 2 个类 m/f。
__label__F Mary
__label__F Santa
...
__label__M John
代码:
#model = fasttext.load_model('model.bin') # using the default model
classifier = fasttext.supervised('output.txt','model', label_prefix='__label__',thread=8)
labels = classifier.predict('Maria',k=1)
print(labels)
当我用一个名字测试时它返回
[[],[],[],[]]
我不明白我的错误在哪里。 我遵循了 fastext github 中的代码行.当相同的代码能够在 Linux 中运行时,Windows 中会产生什么问题?
我使用的是 windows,python 3.4x。
更新: 我评论了 model = fasttext.load .....
这样学习到的监督分类器模型就保存在model.bin中。相同的代码在 Ubuntu 中有效,但在 Windows 中无效。 任何帮助表示赞赏。
最佳答案
在 Windows 上,您还必须安装 fasttext-win
:
pip install fasttext-win
关于python - 在 Windows 中测试时,使用 fasttext api 的监督分类返回空数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49575145/