Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fit the Tokenizer on some data before using tfidf mode #4

Open
bukharilab opened this issue Aug 16, 2018 · 0 comments
Open

Fit the Tokenizer on some data before using tfidf mode #4

bukharilab opened this issue Aug 16, 2018 · 0 comments

Comments

@bukharilab
Copy link

Hi,
I am trying to run your code. However, I am getting the following error. I have fitted the tokenizer as following.

tokenizer.fit_on_texts(train_posts)

print(tokenizer.texts_to_matrix(train_posts, mode='count'))

I am using python 3 with keras 2.2.2 and tensorflow 1.9.0. Can you please help me to fox this issue?

Thanks
----------------- Error -----------------------
Traceback (most recent call last):
File "", line 1, in
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_umd.py", line 194, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/Ahmad/mydevelopment/datasciencePractice/textclassificationwithleras.py", line 99, in
x_train = tokenizer.texts_to_matrix(train_posts, mode='tfidf')
File "/Users/Ahmad/anaconda3/envs/datasciencePractice/lib/python3.6/site-packages/keras_preprocessing/text.py", line 376, in texts_to_matrix
return self.sequences_to_matrix(sequences, mode=mode)
File "/Users/Ahmad/anaconda3/envs/datasciencePractice/lib/python3.6/site-packages/keras_preprocessing/text.py", line 403, in sequences_to_matrix
raise ValueError('Fit the Tokenizer on some data '
ValueError: Fit the Tokenizer on some data before using tfidf mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant