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
how to predict on new data? #9
Comments
Hi @erdnaxel In the original GibbsLDA++, topics of unseed documents are inferred in another round of Gibbs sampling. I haven't implemented this function, because I didn't think many people separate fitting and prediction steps with LDA. With the current version, you can still predict topics of unseen documents using the distribution of topic over words (phi). Here, predict <- function(x, newdata = NULL) {
if (!is.null(x)) {
data <- newdata
} else {
data <- x$data
}
data <- dfm_match(data, colnames(x$phi))
temp <- data %*% t(x$phi)
result <- factor(max.col(temp), labels = rownames(x$phi),
levels = seq_len(nrow(x$phi)))
result[rowSums(data) == 0] <- NA
return(result)
} Please be aware that the result of |
Came here for the same question as @erdnaxel. Great work! |
thank you, i really appreciate the response! i will try it out as soon as i can. |
Guys, I created |
I close this as the branch is merged, so please open a new issue if there are problems. |
hello:
love the package!!
i’m wondering how to apply the model to new data?
The text was updated successfully, but these errors were encountered: