question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: list.remove(x): x not in list in model.hierarchical_topic_reduction()

See original GitHub issue

I created a model with

model= Top2Vec(documents_text2, min_count = 4,
                       speed = "fast-learn", 
                       document_ids=document_ids2, 
                       workers = workers_n,keep_documents=False)

Then I tried to reduce the number of topics with

model.hierarchical_topic_reduction()

and get this error

model10 = model.hierarchical_topic_reduction(1000)
Traceback (most recent call last):

  File "<ipython-input-12-4ee6e263e4a0>", line 1, in <module>
    model10 = model.hierarchical_topic_reduction(1000)

  File "C:\Users\anaconda\.conda\envs\top2vec_final\lib\site-packages\top2vec\Top2Vec.py", line 1215, in hierarchical_topic_reduction
    ix_keep.remove(most_sim)

ValueError: list.remove(x): x not in list

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
p-drecommented, Dec 1, 2020

First I load the model an tested the reducing again. Same error

model = Top2Vec.load("Top2vec_model")

test = model.hierarchical_topic_reduction(200)
Traceback (most recent call last):

  File "<ipython-input-37-4e020d4f68c8>", line 1, in <module>
    test = model.hierarchical_topic_reduction(200)

  File "C:\Users\anaconda\.conda\envs\top2vec_final\lib\site-packages\top2vec\Top2Vec.py", line 1215, in hierarchical_topic_reduction
    ix_keep.remove(most_sim)

ValueError: list.remove(x): x not in list

After that I run:

top_vecs = model.topic_vectors
sizes = model.topic_sizes
smallest = sizes.sort_values(ascending=True).index[0]
res = np.inner(top_vecs[smallest], top_vecs)
most_sim = np.flip(np.argsort(res))[1]

most_sim
57

smallest
19904
1reaction
MackieBlackburncommented, Dec 1, 2020

Could it be that most_sim == smallest because two topics have a similarity of 1, so somehow “smallest” ends up in index 1 of flip(res)? In that case the topic would already be removed by line 1214. I am in the process of verifying this but I am only getting this error when the number of topics is very large and that takes a long time to run.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python throws ValueError: list.remove(x): x not in list
Removing items from a list you are looping over twice makes things a little more complicated still, resulting in a ValueError:
Read more >
ValueError: list.remove(x): x not in list - STechies
This error is generated when we try to remove a list item that is not present in the list while using the remove(...
Read more >
Python ValueError: list.remove(x): x not in list Solution
The ValueError: list.remove(x): x not in list Python error tells us we are using the remove() method to remove an item that does...
Read more >
I keep getting "ValueError: list.remove(x): x not in list" - Reddit
The problem is list.remove() expects the element to be deleted, not it's index.
Read more >
ValueError: list.remove(x): x not in list · Issue #139 - GitHub
When I use python setup.py install to install, the terminal will display the following information. setup.py:66: UserWarning: Assuming ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found