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

metadata length assertion error #27

Open
choltz95 opened this issue Mar 16, 2018 · 1 comment
Open

metadata length assertion error #27

choltz95 opened this issue Mar 16, 2018 · 1 comment

Comments

@choltz95
Copy link

choltz95 commented Mar 16, 2018

Hi, I am getting the following assertion error when I include the metadata parameter.
assert len(metadata) == len(data['labels'])

I am not sure I understand the error. When I check, the length of the column I am using as my metadata is the same as the length of my label column. Is there anything else I should be checking?

When I test the demo program I get no error.

Here is some relevant code:
corpus = st.CorpusFromPandas(df, category_col='binary_bias', text_col='content',nlp=nlp).build()

html = st.produce_scattertext_explorer(corpus,category='left',category_name='Left',not_category_name='Right',width_in_pixels=1000,metadata=df['topic'])

@JasonKessler
Copy link
Owner

This error crops up when documents are either empty or composed of very infrequent tokens. I'm working on fixing this, but in the meantime, please try a couple things:

Instead of metadata=df['topic'], try metadata=corpus.get_df()['topic'].

If that doesn't work, please try

st.produce_scattertext_explorer(corpus,category='left',category_name='Left',not_category_name='Right',width_in_pixels=1000,metadata=corpus.get_df()['topic'], minimum_term_frequency=0)

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

2 participants