public static void main (String[] args) throws IOException { InstanceList ilist = InstanceList.load (new File(args[0])); int numIterations = args.length > 1 ? Integer.parseInt(args[1]) : 1000; int numTopWords = args.length > 2 ? Integer.parseInt(args[2]) : 20; int numSuperTopics = args.length > 3 ? Integer.parseInt(args[3]) : 10; int numSubTopics = args.length > 4 ? Integer.parseInt(args[4]) : 10; System.out.println ("Data loaded."); PAM4L pam = new PAM4L (numSuperTopics, numSubTopics); pam.estimate (ilist, numIterations, 50, 0, 50, null, new Randoms()); // should be 1100 pam.printTopWords (numTopWords, true); // pam.printDocumentTopics (new File(args[0]+".pam")); }
public void printDocumentTopics (File f) throws IOException { printDocumentTopics (new PrintWriter (new BufferedWriter( new FileWriter (f))), 0.0, -1); }
public void printState (File f) throws IOException { printState (new PrintWriter (new BufferedWriter (new FileWriter(f)))); }
long iterationStart = System.currentTimeMillis(); clearHistograms(); sampleTopicsForAllDocs (r); if (showTopicsInterval != 0 && iterations % showTopicsInterval == 0) { System.out.println (); printTopWords (5, false); long optimizeTime = System.currentTimeMillis(); for (superTopic = 0; superTopic < numSuperTopics; superTopic++) { learnParameters(subAlphas[superTopic], subTopicHistograms[superTopic], superTopicHistograms[superTopic]); printWordCounts();
if (inputModelFilename.value != null) throw new IllegalArgumentException ("--input-model not supported with --use-pam."); PAM4L pam = new PAM4L(pamNumSupertopics.value, pamNumSubtopics.value); pam.estimate (ilist, numIterations.value, /*optimizeModelInterval*/50, showTopicsInterval.value, outputModelInterval.value, outputModelFilename.value, randomSeed.value == 0 ? new Randoms() : new Randoms(randomSeed.value)); pam.printTopWords(topWords.value, true); if (stateFile.value != null) pam.printState (new File(stateFile.value)); if (docTopicsFile.value != null) { PrintWriter out = new PrintWriter (new FileWriter ((new File(docTopicsFile.value)))); pam.printDocumentTopics (out, docTopicsThreshold.value, docTopicsMax.value); out.close();
private void sampleTopicsForAllDocs (Randoms r) { // Loop over every word in the corpus for (int di = 0; di < superTopics.length; di++) { sampleTopicsForOneDoc ((FeatureSequence)ilist.get(di).getData(), superTopics[di], subTopics[di], r); } }
long iterationStart = System.currentTimeMillis(); clearHistograms(); sampleTopicsForAllDocs (r); if (showTopicsInterval != 0 && iterations % showTopicsInterval == 0) { System.out.println (); printTopWords (5, false); long optimizeTime = System.currentTimeMillis(); for (superTopic = 0; superTopic < numSuperTopics; superTopic++) { learnParameters(subAlphas[superTopic], subTopicHistograms[superTopic], superTopicHistograms[superTopic]); printWordCounts();
if (inputModelFilename.value != null) throw new IllegalArgumentException ("--input-model not supported with --use-pam."); PAM4L pam = new PAM4L(pamNumSupertopics.value, pamNumSubtopics.value); pam.estimate (ilist, numIterations.value, /*optimizeModelInterval*/50, showTopicsInterval.value, outputModelInterval.value, outputModelFilename.value, randomSeed.value == 0 ? new Randoms() : new Randoms(randomSeed.value)); pam.printTopWords(topWords.value, true); if (stateFile.value != null) pam.printState (new File(stateFile.value)); if (docTopicsFile.value != null) { PrintWriter out = new PrintWriter (new FileWriter ((new File(docTopicsFile.value)))); pam.printDocumentTopics (out, docTopicsThreshold.value, docTopicsMax.value); out.close();
private void sampleTopicsForAllDocs (Randoms r) { // Loop over every word in the corpus for (int di = 0; di < superTopics.length; di++) { sampleTopicsForOneDoc ((FeatureSequence)ilist.get(di).getData(), superTopics[di], subTopics[di], r); } }
long iterationStart = System.currentTimeMillis(); clearHistograms(); sampleTopicsForAllDocs (r); if (showTopicsInterval != 0 && iterations % showTopicsInterval == 0) { System.out.println (); printTopWords (5, false); long optimizeTime = System.currentTimeMillis(); for (superTopic = 0; superTopic < numSuperTopics; superTopic++) { learnParameters(subAlphas[superTopic], subTopicHistograms[superTopic], superTopicHistograms[superTopic]); printWordCounts();
if (inputModelFilename.value != null) throw new IllegalArgumentException ("--input-model not supported with --use-pam."); PAM4L pam = new PAM4L(pamNumSupertopics.value, pamNumSubtopics.value); pam.estimate (ilist, numIterations.value, /*optimizeModelInterval*/50, showTopicsInterval.value, outputModelInterval.value, outputModelFilename.value, randomSeed.value == 0 ? new Randoms() : new Randoms(randomSeed.value)); pam.printTopWords(topWords.value, true); if (stateFile.value != null) pam.printState (new File(stateFile.value)); if (docTopicsFile.value != null) { PrintWriter out = new PrintWriter (new FileWriter ((new File(docTopicsFile.value)))); pam.printDocumentTopics (out, docTopicsThreshold.value, docTopicsMax.value); out.close();
public static void main (String[] args) throws IOException { InstanceList ilist = InstanceList.load (new File(args[0])); int numIterations = args.length > 1 ? Integer.parseInt(args[1]) : 1000; int numTopWords = args.length > 2 ? Integer.parseInt(args[2]) : 20; int numSuperTopics = args.length > 3 ? Integer.parseInt(args[3]) : 10; int numSubTopics = args.length > 4 ? Integer.parseInt(args[4]) : 10; System.out.println ("Data loaded."); PAM4L pam = new PAM4L (numSuperTopics, numSubTopics); pam.estimate (ilist, numIterations, 50, 0, 50, null, new Randoms()); // should be 1100 pam.printTopWords (numTopWords, true); // pam.printDocumentTopics (new File(args[0]+".pam")); }
private void sampleTopicsForAllDocs (Randoms r) { // Loop over every word in the corpus for (int di = 0; di < superTopics.length; di++) { sampleTopicsForOneDoc ((FeatureSequence)ilist.get(di).getData(), superTopics[di], subTopics[di], r); } }
public void printState (File f) throws IOException { printState (new PrintWriter (new BufferedWriter (new FileWriter(f)))); }
public void printDocumentTopics (File f) throws IOException { printDocumentTopics (new PrintWriter (new BufferedWriter( new FileWriter (f))), 0.0, -1); }
public static void main (String[] args) throws IOException { InstanceList ilist = InstanceList.load (new File(args[0])); int numIterations = args.length > 1 ? Integer.parseInt(args[1]) : 1000; int numTopWords = args.length > 2 ? Integer.parseInt(args[2]) : 20; int numSuperTopics = args.length > 3 ? Integer.parseInt(args[3]) : 10; int numSubTopics = args.length > 4 ? Integer.parseInt(args[4]) : 10; System.out.println ("Data loaded."); PAM4L pam = new PAM4L (numSuperTopics, numSubTopics); pam.estimate (ilist, numIterations, 50, 0, 50, null, new Randoms()); // should be 1100 pam.printTopWords (numTopWords, true); // pam.printDocumentTopics (new File(args[0]+".pam")); }
public void printState (File f) throws IOException { printState (new PrintWriter (new BufferedWriter (new FileWriter(f)))); }
public void printDocumentTopics (File f) throws IOException { printDocumentTopics (new PrintWriter (new BufferedWriter( new FileWriter (f))), 0.0, -1); }