Skip to content

Conversation

@x-tabdeveloping
Copy link
Owner

@x-tabdeveloping x-tabdeveloping commented Jan 31, 2025

You can now add a seed_phrase to a KeyNMF model, which essentially indicates the aspect, from which the model has to examine documents.

from sklearn.datasets import fetch_20newsgroups

from turftopic import KeyNMF

corpus = fetch_20newsgroups(
    subset="all",
    remove=("headers", "footers", "quotes"),
).data

model = KeyNMF(5, seed_phrase="Is homosexuality moral?")
model.fit(corpus)

model.print_topics()
Topic ID Highest Ranking
0 homosexuality, homosexual, immoral, sodom, heterosexual, sexual, fornication, christians, verses, sex
1 morality, moral, immoral, morals, objective, morally, society, animals, behavior, natural
2 christians, christian, christianity, religion, bible, god, church, religious, faith, beliefs
3 homosexual, homosexuals, heterosexual, gay, sexual, sex, heterosexuals, straight, men, sexuality
4 sin, sins, god, sinner, sinful, condemnation, sinned, scripture, punishment, sinners

TODO:

  • Add documentation
  • Release new version

@x-tabdeveloping x-tabdeveloping changed the title WIP: Added seed phrases to KeyNMF Added seed phrases to KeyNMF Feb 1, 2025
@x-tabdeveloping
Copy link
Owner Author

@KennethEnevoldsen can I has review?

Copy link
Collaborator

@KennethEnevoldsen KennethEnevoldsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great a few ideas to restructure the docs - nothing holding back this PR though

@x-tabdeveloping x-tabdeveloping merged commit ab2787e into main Feb 17, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

3 participants