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 void
calculateNCRP(com.carrotsearch.hppc.ObjectDoubleHashMap<cc.mallet.topics.HierarchicalLDA.NCRPNode> nodeWeights, cc.mallet.topics.HierarchicalLDA.NCRPNode node, double weight)
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)
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.void
estimate(int numIterations)
void
initialize(InstanceList instances, InstanceList testing, int numLevels, Randoms random)
static void
main(java.lang.String[] args)
This method is primarily for testing purposes.void
printNode(cc.mallet.topics.HierarchicalLDA.NCRPNode node, int indent, boolean withWeight)
void
printNodes()
void
printNodes(boolean withWeight)
void
printState()
Writes the current sampling state to the file specified instateFile
.void
printState(java.io.PrintWriter out)
Write a text file describing the current sampling state.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.static HierarchicalLDA
read(java.io.File f)
void
samplePath(int doc, int iteration)
void
sampleTopics(int doc)
void
setAlpha(double alpha)
void
setEta(double eta)
void
setGamma(double gamma)
void
setProgressDisplay(boolean showProgress)
This parameter determines whether the sampler outputs shows progress by outputting a character after every iteration.void
setStateFile(java.lang.String stateFile)
void
setTopicDisplay(int interval, int words)
void
write(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.FileNotFoundException
Writes the current sampling state to the file specified instateFile
.- Throws:
java.io.IOException
java.io.FileNotFoundException
-
printState
public void printState(java.io.PrintWriter out) throws java.io.IOException
Write 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. TheHierarchicalLDATUI
class has a more flexible interface for command-line use.
-
-