python - 在 Windows 中测试时,使用 fasttext api 的监督分类返回空数组

标签 python machine-learning classification fasttext

我正在尝试使用快速文本 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

参见此处:https://pypi.org/project/fasttext-win/

关于python - 在 Windows 中测试时,使用 fasttext api 的监督分类返回空数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49575145/

相关文章:

python - 在 Python 中将函数的结果存储到可检索的 DataFrame 中

python - chrome 无法使用 python selenium chromedriver 加载

python - 尝试将多个函数聚合到新列时出现意外的 KeyError Pandas

machine-learning - 训练精度非常高,验证精度非常高,但测试集精度非常低

r - 在 R 中使用 k-NN(类包)的最近邻索引

python - 如何使用 BeautifulSoup 选择 href 类标签?

python - scikit-learn - 以概率为目标变量的多项逻辑回归

c++ - 从哪里获得用于面部表情识别的 SVM 训练数据?

machine-learning - Weka 中的分类器选项呈灰色

text - weka 中的一元类文本分类?