微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

fastText test_label在文本分类中显示所有标签的召回为nan

如何解决fastText test_label在文本分类中显示所有标签的召回为nan

在使用fastText训练监督模型之后,我尝试通过以下方法获取每个标签的指标:

model.test_label('testdata.txt')

但是,对于每个标签的召回,我都很满意。输出一个示例是

'__label__Facility': {'precision': 0.7272727272727273,'recall': nan,'f1score': 1.4545454545454546},'f1score': 1.1415356151711378},'__label__ThirdParty': {'precision': 0.8731285988483686,'f1score': 1.7462571976967372},'__label__Orders': {'precision': 0.6527777777777778,'f1score': 1.3055555555555556}

这里提到了相同的问题: FastText recall is 'nan' but precision is a number

我尝试了该问题中提到的修复程序,并在Anaconda Prompt中运行了以下命令:

pip install git+https://github.com/facebookresearch/fastText.git@b64e359d5485dda4b4b5074494155d18e25c8d13

我在jupyter笔记本中重新运行了代码,但是仍然遇到相同的问题。我尝试关闭内核并启动一个新内核,以查看它是否会有所作为,但问题仍然存在。

似乎安装成功,所以我不确定是什么问题。如果有帮助,这是Anaconda提示符的输出

(py38) C:\>pip install git+https://github.com/facebookresearch/fastText.git@b64e359d5485dda4b4b5074494155d18e25c8d13
Collecting git+https://github.com/facebookresearch/fastText.git@b64e359d5485dda4b4b5074494155d18e25c8d13
  cloning https://github.com/facebookresearch/fastText.git (to revision b64e359d5485dda4b4b5074494155d18e25c8d13) to c:\users\ebf\appdata\local\temp\pip-req-build-iy1g1acw
Requirement already satisfied (use --upgrade to upgrade): fasttext==0.9.2 from git+https://github.com/facebookresearch/fastText.git@b64e359d5485dda4b4b5074494155d18e25c8d13 in c:\users\ebf\appdata\local\continuum\anaconda3\envs\py38\lib\site-packages
Requirement already satisfied: pybind11>=2.2 in c:\users\ebf\appdata\local\continuum\anaconda3\envs\py38\lib\site-packages (from fasttext==0.9.2) (2.5.0)
Requirement already satisfied: setuptools>=0.7.0 in c:\users\ebf\appdata\local\continuum\anaconda3\envs\py38\lib\site-packages (from fasttext==0.9.2) (49.6.0.post20200814)
Requirement already satisfied: numpy in c:\users\ebf\appdata\local\continuum\anaconda3\envs\py38\lib\site-packages (from fasttext==0.9.2) (1.19.1)
Building wheels for collected packages: fasttext
  Building wheel for fasttext (setup.py) ... done
  Created wheel for fasttext: filename=fasttext-0.9.2-cp38-cp38-win_amd64.whl size=225331 sha256=a76754f5819d96f33256a934c19e6676af79f53bfcfb088d3f555b6736e961bf
  Stored in directory: c:\users\ebf\appdata\local\pip\cache\wheels\5e\e2\b4\d7d10e1cef8c0b9afc1669ed987ee5e970d800079ec14d2cbf
Successfully built fasttext

有什么建议吗?

解决方法

同样的事情。只是 pip uninstall fasttext 先帮了忙。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。