Skip to content

Commit

Permalink
evaluator now listens to random seed
Browse files Browse the repository at this point in the history
  • Loading branch information
mimno committed Aug 10, 2015
1 parent 33fb628 commit b0899b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/cc/mallet/topics/MarginalProbEstimator.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ public MarginalProbEstimator (int numTopics,
Integer.toBinaryString(topicMask) + " topic mask");

}

public void setRandomSeed(int seed) {
if (seed == -1) {
this.random = new Randoms();
}
else {
this.random = new Randoms(seed);
}
}

public void setRandom(Randoms r) {
this.random = r;
}

public int[] getTokensPerTopic() { return tokensPerTopic; }
public int[][] getTypeTopicCounts() { return typeTopicCounts; }
Expand All @@ -105,7 +118,6 @@ public void setPrintWords(boolean shouldPrint) {

public double evaluateLeftToRight (InstanceList testing, int numParticles, boolean usingResampling,
PrintStream docProbabilityStream) {
random = new Randoms();

double logNumParticles = Math.log(numParticles);
double totalLogLikelihood = 0;
Expand Down
6 changes: 4 additions & 2 deletions src/cc/mallet/topics/tui/EvaluateTopics.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public class EvaluateTopics {
"The number of iterations before the first sample is saved.", null);

static CommandOption.Integer randomSeed = new CommandOption.Integer
(EvaluateTopics.class, "random-seed", "INTEGER", true, 0,
"The random seed for the Gibbs sampler. Default is 0, which will use the clock.", null);
(EvaluateTopics.class, "random-seed", "INTEGER", true, -1,
"The random seed for the Gibbs sampler. Default is -1, which will use the clock.", null);

public static void main (String[] args) {

Expand Down Expand Up @@ -92,6 +92,8 @@ public static void main (String[] args) {
MarginalProbEstimator.read(new File(evaluatorFilename.value));

evaluator.setPrintWords(showWords.value);

evaluator.setRandomSeed(randomSeed.value);

InstanceList instances = InstanceList.load (new File(inputFile.value));

Expand Down

0 comments on commit b0899b3

Please sign in to comment.