Fasttext: fasttext supervised classification return empty array on testing the classifier

Created on 2 Apr 2018  Â·  10Comments  Â·  Source: facebookresearch/fastText

Windows,
Python 3.4
Pycharm

Issue: same code work in Ubuntu but not in windows.

I am trying to build a supervised classifier using fast text API. My data is 'output.txt' with 15000 rows, 2 columns (gender and name) and 2 classes m/f.
__label__F Mary __label__F Santa ... __label__M John

my code is
`classifier = fasttext.supervised('output.txt','model', label_prefix='__label__',thread=8)

labels = classifier.predict('Maria',k=1)
print(labels) the output is [[],[],[],[]]`

The learnt supervised classifier model is saved in model.bin

how to find the problem, because same code is able to work in Ubuntu ( my friends pc) and gives an accuracy of 94 %. Any help appreciated.

Most helpful comment

I have the same problem on Windows (py3.6 x64 / fasttext 0.8.3)

classifier = fasttext.supervised('train.txt',
                                 'model',
                                 label_prefix='__label__',
                                 epoch=100,
                                 silent=False)

print(classifier.label_prefix)
print(classifier.labels)

labels = classifier.predict(['Еду в Магадан', 'В Магадан!'])
print(labels)

Output:

Read 0M words
Number of words:  170
Number of labels: 2
Progress: 100.0%  words/sec/thread: 2133905  lr: 0.000000  loss: 0.202012  eta: 0h0m 
__label__
[]
[[], []]

It seems the labels were lost.
This code works fine on Ubuntu.

The same: https://github.com/salestock/fastText.py/issues/112

@raady07 Why did you close this issue? The problem still exists.

All 10 comments

It would be better if you include what exactly is the error you are getting.

I am not getting any error or output when I use the same chunk of code in windows, I have reinstalled fasttext and dont know why it returns an empty array instead of sending some probability for the test word.

+1, have the same problem

I think you should set label_prefix="__label__"

Try the label_prefix="__label__", not work

Do you have the exact same line as below in your friends's code, successfully running on Ubuntu?
classifier = fasttext.supervised('output.txt','model', label_prefix='label',thread=8)
and not the following :
classifier = fasttext.supervised('output.txt','model', label_prefix='__label__',thread=8)

Read in some blogs (unfortunately, I currently don't have the link), Fasttext works in Linux and still updating for Windows.

I have the same problem, it works for mac, but not work for win10

Same problem persistent with Debian VM instance in Google Cloud. Any solution?

I have the same problem on Windows (py3.6 x64 / fasttext 0.8.3)

classifier = fasttext.supervised('train.txt',
                                 'model',
                                 label_prefix='__label__',
                                 epoch=100,
                                 silent=False)

print(classifier.label_prefix)
print(classifier.labels)

labels = classifier.predict(['Еду в Магадан', 'В Магадан!'])
print(labels)

Output:

Read 0M words
Number of words:  170
Number of labels: 2
Progress: 100.0%  words/sec/thread: 2133905  lr: 0.000000  loss: 0.202012  eta: 0h0m 
__label__
[]
[[], []]

It seems the labels were lost.
This code works fine on Ubuntu.

The same: https://github.com/salestock/fastText.py/issues/112

@raady07 Why did you close this issue? The problem still exists.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pengyu picture pengyu  Â·  3Comments

loretoparisi picture loretoparisi  Â·  3Comments

poppingtonic picture poppingtonic  Â·  3Comments

hughbzhang picture hughbzhang  Â·  3Comments

loretoparisi picture loretoparisi  Â·  3Comments