Skip to content

Instantly share code, notes, and snippets.

@ypanagis
ypanagis / topicmodels_json_ldavis.R
Last active July 27, 2016 10:05
Prepare the output of an LDA model for use in LDAVis where corpus is created with the quanteda package
#' Convert the output of a topicmodels Latent Dirichlet Allocation to JSON
#' for use with LDAvis
#'
#' @param fitted Output from a topicmodels \code{LDA} model.
#' @param corp Corpus object used to create the document term.
#' The corpus should be created with the \tm{quanteda} package
#' matrix for the \code{LDA} model. This should have been created with
#' the tm package's \code{Corpus} function.
#' @param doc_term The document term matrix used in the \code{LDA}
#' model. This should have been created with the quanteda package's
@ypanagis
ypanagis / gephi_del.py
Last active October 20, 2022 14:40
Gephi gist to delete all nodes with specific attribute (Modularity class)
# Delete some nodes from Gephi graph
# run from Gephi scripting console as execfile("/Fullpath/gephi_del.py") or
# execfile("C:\\Fullpath\\gephi_del.py") for windows
# Delete all nodes from Modularity class 5
subgraph = g.filter(modularity_class == 5) # first filter those out to a new subgraph
# Then iterate and delete
for v in subgraph.nodes:
print v.label # just testing which node is accessed
del v