effy
effy

Reputation: 21

fastText test_label shows recall as nan for all labels in text classification

After training a supervised model with fastText, I try to get the metrics for each label with:

model.test_label('testdata.txt')

However, I get nan for every label's recall. An example of the output is

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

The same problem is mentioned here: FastText recall is 'nan' but precision is a number

I tried the fix mentioned in that issue, running the following in my Anaconda Prompt:

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

I re-ran my code in jupyter notebook but I keep having the same issue. I tried shutting down the kernel and starting a new one to see if it would make a difference, but the issue remains.

It seems like it's installing successfully, so I'm not sure what the problem is. This is the output from Anaconda prompt in case it's helpful:

(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

Any suggestions?

Upvotes: 2

Views: 901

Answers (1)

Sergey Leyko
Sergey Leyko

Reputation: 369

same thing. Just pip uninstall fasttext first helped.

Upvotes: 1

Related Questions