public static void main (String[] args) { try { InstanceList training = InstanceList.load (new File(args[0])); int numTopics = args.length > 1 ? Integer.parseInt(args[1]) : 200; ParallelTopicModel lda = new ParallelTopicModel (numTopics, 50.0, 0.01); lda.printLogLikelihood = true; lda.setTopicDisplay(50, 7); lda.addInstances(training); lda.setNumThreads(Integer.parseInt(args[2])); lda.estimate(); logger.info("printing state"); lda.printState(new File("state.gz")); logger.info("finished printing"); } catch (Exception e) { e.printStackTrace(); } }
public static void main (String[] args) { try { InstanceList training = InstanceList.load (new File(args[0])); int numTopics = args.length > 1 ? Integer.parseInt(args[1]) : 200; ParallelTopicModel lda = new ParallelTopicModel (numTopics, 50.0, 0.01); lda.printLogLikelihood = true; lda.setTopicDisplay(50, 7); lda.addInstances(training); lda.setNumThreads(Integer.parseInt(args[2])); lda.estimate(); logger.info("printing state"); lda.printState(new File("state.gz")); logger.info("finished printing"); } catch (Exception e) { e.printStackTrace(); } }
public static void main (String[] args) { try { InstanceList training = InstanceList.load (new File(args[0])); int numTopics = args.length > 1 ? Integer.parseInt(args[1]) : 200; ParallelTopicModel lda = new ParallelTopicModel (numTopics, 50.0, 0.01); lda.printLogLikelihood = true; lda.setTopicDisplay(50, 7); lda.addInstances(training); lda.setNumThreads(Integer.parseInt(args[2])); lda.estimate(); logger.info("printing state"); lda.printState(new File("state.gz")); logger.info("finished printing"); } catch (Exception e) { e.printStackTrace(); } }
topicModel.setTopicDisplay(showTopicsInterval.value, topWords.value);
/** * Estimate a topic model for collaborative filtering data. * * @param <U> user type * @param <I> item type * @param preferences preference data * @param k number of topics * @param alpha alpha in model * @param beta beta in model * @param numIterations number of iterations * @param burninPeriod burnin period * @return a topic model * @throws IOException when internal IO error occurs */ public static <U, I> ParallelTopicModel estimate(FastPreferenceData<U, I> preferences, int k, double alpha, double beta, int numIterations, int burninPeriod) throws IOException { ParallelTopicModel topicModel = new ParallelTopicModel(k, alpha * k, beta); topicModel.addInstances(new LDAInstanceList<>(preferences)); topicModel.setTopicDisplay(numIterations + 1, 0); topicModel.setNumIterations(numIterations); topicModel.setBurninPeriod(burninPeriod); topicModel.setNumThreads(Runtime.getRuntime().availableProcessors()); topicModel.estimate(); return topicModel; }
topicModel.setTopicDisplay(showTopicsInterval.value, topWords.value);
topicModel.setTopicDisplay(showTopicsInterval.value, topWords.value);
topicModel.setTopicDisplay(showTopicsInterval.value, topWords.value);
topicModel.setTopicDisplay(showTopicsInterval.value, topWords.value);
topicModel.setTopicDisplay(showTopicsInterval.value, topWords.value);
@Override public void collectionProcessComplete() throws AnalysisEngineProcessException { try { ParallelTopicModel model = new ParallelTopicModel(nTopics, alphaSum, beta); model.addInstances(getInstanceList()); model.setNumThreads(getNumThreads()); model.setNumIterations(nIterations); model.setBurninPeriod(burninPeriod); model.setOptimizeInterval(optimizeInterval); model.setRandomSeed(randomSeed); model.setSaveSerializedModel(saveInterval, getTargetLocation()); model.setSymmetricAlpha(useSymmetricAlpha); model.setTopicDisplay(displayInterval, displayNTopicWords); model.estimate(); getLogger().info("Writing model to " + getTargetLocation()); File targetFile = new File(getTargetLocation()); if (targetFile.getParentFile() != null) { targetFile.getParentFile().mkdirs(); } model.write(targetFile); } catch (IOException | SecurityException e) { throw new AnalysisEngineProcessException(e); } }
model.addInstances(instances); model.setNumThreads(1); // Important, since this is being run in the reduce, just use one thread model.setTopicDisplay(0,0); model.setNumIterations(2000); model.estimate();