After Gibbs sampling, the count matrices hold the final topic assignments. The usual point estimates add the Dirichlet priors back in:
theta[d, k] = (n_dk + alpha) / (sum_k' n_dk' + K alpha).phi[k, w] = (n_kw + beta) / (sum_w' n_kw' + V beta).Implement lda_estimates(doc_topic, topic_word, alpha, beta), which returns (theta, phi).
doc_topic is (D, K) with nonnegative counts. topic_word is (K, V) with nonnegative counts.theta has shape (D, K), and phi has shape (K, V). Each row of both sums to 1.doc_topic has K columns and topic_word has K rows). Otherwise raise ValueError.alpha > 0 and beta > 0. Otherwise raise ValueError.ValueError.Add the prior to every cell, then divide by the row sum of the smoothed counts. Equivalently, the denominator is row_total + K alpha for theta and row_total + V beta for phi.
No results yet
Run your code to check it against the examples, or submit to run every test.