Package cc.mallet.topics
Class HierarchicalLDA
- java.lang.Object
-
- cc.mallet.topics.HierarchicalLDA
-
- All Implemented Interfaces:
java.io.Serializable
public class HierarchicalLDA extends java.lang.Object implements java.io.Serializable- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description HierarchicalLDA()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcalculateNCRP(com.carrotsearch.hppc.ObjectDoubleHashMap<cc.mallet.topics.HierarchicalLDA.NCRPNode> nodeWeights, cc.mallet.topics.HierarchicalLDA.NCRPNode node, double weight)voidcalculateWordLikelihood(com.carrotsearch.hppc.ObjectDoubleHashMap<cc.mallet.topics.HierarchicalLDA.NCRPNode> nodeWeights, cc.mallet.topics.HierarchicalLDA.NCRPNode node, double weight, com.carrotsearch.hppc.IntIntHashMap[] typeCounts, double[] newTopicWeights, int level, int iteration)doubleempiricalLikelihood(int numSamples, InstanceList testing)For use with empirical likelihood evaluation: sample a path through the tree, then sample a multinomial over topics in that path, then return a weighted sum of words.voidestimate(int numIterations)voidinitialize(InstanceList instances, InstanceList testing, int numLevels, Randoms random)static voidmain(java.lang.String[] args)This method is primarily for testing purposes.voidprintNode(cc.mallet.topics.HierarchicalLDA.NCRPNode node, int indent, boolean withWeight)voidprintNodes()voidprintNodes(boolean withWeight)voidprintState()Writes the current sampling state to the file specified instateFile.voidprintState(java.io.PrintWriter out)Write a text file describing the current sampling state.voidpropagateTopicWeight(com.carrotsearch.hppc.ObjectDoubleHashMap<cc.mallet.topics.HierarchicalLDA.NCRPNode> nodeWeights, cc.mallet.topics.HierarchicalLDA.NCRPNode node, double weight)Propagate a topic weight to a node and all its children.static HierarchicalLDAread(java.io.File f)voidsamplePath(int doc, int iteration)voidsampleTopics(int doc)voidsetAlpha(double alpha)voidsetEta(double eta)voidsetGamma(double gamma)voidsetProgressDisplay(boolean showProgress)This parameter determines whether the sampler outputs shows progress by outputting a character after every iteration.voidsetStateFile(java.lang.String stateFile)voidsetTopicDisplay(int interval, int words)voidwrite(java.io.File serializedModelFile)
-
-
-
Method Detail
-
setAlpha
public void setAlpha(double alpha)
-
setGamma
public void setGamma(double gamma)
-
setEta
public void setEta(double eta)
-
setStateFile
public void setStateFile(java.lang.String stateFile)
-
setTopicDisplay
public void setTopicDisplay(int interval, int words)
-
setProgressDisplay
public void setProgressDisplay(boolean showProgress)
This parameter determines whether the sampler outputs shows progress by outputting a character after every iteration.
-
initialize
public void initialize(InstanceList instances, InstanceList testing, int numLevels, Randoms random)
-
estimate
public void estimate(int numIterations)
-
samplePath
public void samplePath(int doc, int iteration)
-
calculateNCRP
public void calculateNCRP(com.carrotsearch.hppc.ObjectDoubleHashMap<cc.mallet.topics.HierarchicalLDA.NCRPNode> nodeWeights, cc.mallet.topics.HierarchicalLDA.NCRPNode node, double weight)
-
calculateWordLikelihood
public void calculateWordLikelihood(com.carrotsearch.hppc.ObjectDoubleHashMap<cc.mallet.topics.HierarchicalLDA.NCRPNode> nodeWeights, cc.mallet.topics.HierarchicalLDA.NCRPNode node, double weight, com.carrotsearch.hppc.IntIntHashMap[] typeCounts, double[] newTopicWeights, int level, int iteration)
-
propagateTopicWeight
public void propagateTopicWeight(com.carrotsearch.hppc.ObjectDoubleHashMap<cc.mallet.topics.HierarchicalLDA.NCRPNode> nodeWeights, cc.mallet.topics.HierarchicalLDA.NCRPNode node, double weight)Propagate a topic weight to a node and all its children. weight is assumed to be a log.
-
sampleTopics
public void sampleTopics(int doc)
-
printState
public void printState() throws java.io.IOException, java.io.FileNotFoundExceptionWrites the current sampling state to the file specified instateFile.- Throws:
java.io.IOExceptionjava.io.FileNotFoundException
-
printState
public void printState(java.io.PrintWriter out) throws java.io.IOExceptionWrite a text file describing the current sampling state.- Throws:
java.io.IOException
-
printNodes
public void printNodes()
-
printNodes
public void printNodes(boolean withWeight)
-
printNode
public void printNode(cc.mallet.topics.HierarchicalLDA.NCRPNode node, int indent, boolean withWeight)
-
empiricalLikelihood
public double empiricalLikelihood(int numSamples, InstanceList testing)For use with empirical likelihood evaluation: sample a path through the tree, then sample a multinomial over topics in that path, then return a weighted sum of words.
-
write
public void write(java.io.File serializedModelFile)
-
read
public static HierarchicalLDA read(java.io.File f) throws java.lang.Exception
- Throws:
java.lang.Exception
-
main
public static void main(java.lang.String[] args)
This method is primarily for testing purposes. TheHierarchicalLDATUIclass has a more flexible interface for command-line use.
-
-