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

KeyError: 21021 #335

Open
MayZ7 opened this issue May 19, 2023 · 0 comments
Open

KeyError: 21021 #335

MayZ7 opened this issue May 19, 2023 · 0 comments

Comments

@MayZ7
Copy link

MayZ7 commented May 19, 2023

Hi,

I had this error message when trying to reduce my topic size. Any suggestion on that? Thanks!

reduced_topic=model.hierarchical_topic_reduction(num_topics=30),

File ~/miniconda3/envs/py310/lib/python3.10/site-packages/pandas/core/indexes/base.py:3081, in Index.get_loc(self, key, method, tolerance)
3080 try:
-> 3081 return self._engine.get_loc(casted_key)
3082 except KeyError as err:

File pandas/_libs/index.pyx:70, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/index.pyx:101, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/hashtable_class_helper.pxi:1625, in pandas._libs.hashtable.Int64HashTable.get_item()

File pandas/_libs/hashtable_class_helper.pxi:1632, in pandas._libs.hashtable.Int64HashTable.get_item()

KeyError: 21021

The above exception was the direct cause of the following exception:

KeyError Traceback (most recent call last)
Cell In[10], line 2
1 ##reduce the number of topics generated from Top2Vec if the machine autormatically generates to many topcis##
----> 2 reduced_topic=model.hierarchical_topic_reduction(num_topics=30)

File ~/miniconda3/envs/py310/lib/python3.10/site-packages/top2vec/Top2Vec.py:1882, in Top2Vec.hierarchical_topic_reduction(self, num_topics)
1878 doc_top = self._calculate_documents_topic(topic_vectors=top_vecs,
1879 document_vectors=self.document_vectors,
1880 dist=False)
1881 topic_sizes = pd.Series(doc_top).value_counts()
-> 1882 top_sizes = [topic_sizes[i] for i in range(0, len(topic_sizes))]
1884 else:
1885 smallest_size = top_sizes.pop(smallest)

File ~/miniconda3/envs/py310/lib/python3.10/site-packages/top2vec/Top2Vec.py:1882, in (.0)
1878 doc_top = self._calculate_documents_topic(topic_vectors=top_vecs,
1879 document_vectors=self.document_vectors,
1880 dist=False)
1881 topic_sizes = pd.Series(doc_top).value_counts()
-> 1882 top_sizes = [topic_sizes[i] for i in range(0, len(topic_sizes))]
1884 else:
1885 smallest_size = top_sizes.pop(smallest)

File ~/miniconda3/envs/py310/lib/python3.10/site-packages/pandas/core/series.py:853, in Series.getitem(self, key)
850 return self._values[key]
852 elif key_is_scalar:
--> 853 return self._get_value(key)
855 if is_hashable(key):
856 # Otherwise index.get_value will raise InvalidIndexError
857 try:
858 # For labels that don't resolve as scalars like tuples and frozensets

File ~/miniconda3/envs/py310/lib/python3.10/site-packages/pandas/core/series.py:961, in Series._get_value(self, label, takeable)
958 return self._values[label]
960 # Similar to Index.get_value, but we do not fall back to positional
--> 961 loc = self.index.get_loc(label)
962 return self.index._get_values_for_loc(self, loc, label)

File ~/miniconda3/envs/py310/lib/python3.10/site-packages/pandas/core/indexes/base.py:3083, in Index.get_loc(self, key, method, tolerance)
3081 return self._engine.get_loc(casted_key)
3082 except KeyError as err:
-> 3083 raise KeyError(key) from err
3085 if tolerance is not None:
3086 tolerance = self._convert_tolerance(tolerance, np.asarray(key))

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