Giter VIP home page Giter VIP logo

Comments (2)

bmill3r avatar bmill3r commented on May 24, 2024 1

Thank you so much for your response. That helps a lot!

from bnp.

chyikwei avatar chyikwei commented on May 24, 2024

Hi,
ASFAIK there is no best way to decide number of topics. HDP just assume the topics are infinite with DP prior (instead of a fix number K) so there is no guarantee it will find the right number of topics for you or the topics you see are consistent across different setting.

In practice, my personal experience is:

  1. when you increase n_topic_truncate, a topic will be split to multiple smaller and similar topics. (This is the same as LDA.)
  2. how you initialize the stick break process also plays an important role on number of topics. You can try beta distribution which I commented out before. (https://github.com/chyikwei/bnp/blob/master/bnp/online_hdp.py#L439-L449)

And for n_topic_truncate=2 case, I tested it with dummy data and the result looks ok (I got 48%, 52% for topic proportion). You might need to turn hyper-parameters for your dataset.

>>> tf = make_doc_word_matrix(n_topics=5,
                              words_per_topic=10,
                              docs_per_topic=100,
                              words_per_doc=20,
                              shuffle=True,
                              random_state=0)

>>> hdp = HierarchicalDirichletProcess(n_topic_truncate=2, n_doc_truncate=3, max_iter=5, random_state=0)
>>> hdp.fit(tf)
HierarchicalDirichletProcess(alpha=1.0, batch_size=256, burn_in_iters=3,
               check_doc_likelihood=False, eta=0.01, evaluate_every=0,
               kappa=0.5, learning_method='online',
               max_doc_update_iter=100, max_iter=5, mean_change_tol=0.001,
               n_doc_truncate=3, n_jobs=1, n_topic_truncate=2, omega=1.0,
               perp_tol=0.1, random_state=0, scale=1.0, tau=10.0,
               total_samples=1000000, verbose=0)
>>> print_top_words(hdp, 10)
Topic 0 (proportion: 0.48): 3 1 7 5 19 10 4 8 0 2
Topic 1 (proportion: 0.52): 48 46 35 31 39 42 30 16 33 45

from bnp.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.