Download BERTopic/tests/test_plotting/test_topics.py from kisejin/TopicModelingRepo: direct link, hf CLI and curl.
- Browser
- Download file 1.78 kB
-
https://huggingface.co/kisejin/TopicModelingRepo/resolve/5ecdc19ebac471cb51415c4e2fa755d81931c0ee/BERTopic/tests/test_plotting/test_topics.py
- Command line
-
hf download hf://kisejin/TopicModelingRepo@5ecdc19ebac471cb51415c4e2fa755d81931c0ee/BERTopic/tests/test_plotting/test_topics.py
-
curl -L -o test_topics.py https://huggingface.co/kisejin/TopicModelingRepo/resolve/5ecdc19ebac471cb51415c4e2fa755d81931c0ee/BERTopic/tests/test_plotting/test_topics.py
1.78 kB
| import copy | |
| import pytest | |
| def test_topics(model, request): | |
| topic_model = copy.deepcopy(request.getfixturevalue(model)) | |
| fig = topic_model.visualize_topics() | |
| for slider in fig.to_dict()["layout"]["sliders"]: | |
| for step in slider["steps"]: | |
| assert int(step["label"].split(" ")[-1]) != -1 | |
| fig = topic_model.visualize_topics(top_n_topics=5) | |
| for slider in fig.to_dict()["layout"]["sliders"]: | |
| for step in slider["steps"]: | |
| assert int(step["label"].split(" ")[-1]) != -1 | |
| def test_topics_outlier(model, request): | |
| topic_model = copy.deepcopy(request.getfixturevalue(model)) | |
| topic_model.topic_sizes_[-1] = 4 | |
| fig = topic_model.visualize_topics() | |
| for slider in fig.to_dict()["layout"]["sliders"]: | |
| for step in slider["steps"]: | |
| assert int(step["label"].split(" ")[-1]) != -1 | |
| fig = topic_model.visualize_topics(top_n_topics=5) | |
| for slider in fig.to_dict()["layout"]["sliders"]: | |
| for step in slider["steps"]: | |
| assert int(step["label"].split(" ")[-1]) != -1 | |