Package cc.mallet.topics

Examples of cc.mallet.topics.HierarchicalLDA


    InstanceList testing = null;
    if (testingFile.value() != null) {
      testing = InstanceList.load(new File(testingFile.value()));
    }
 
    HierarchicalLDA hlda = new HierarchicalLDA();
   
    // Set hyperparameters

    hlda.setAlpha(alpha.value());
    hlda.setGamma(gamma.value());
    hlda.setEta(eta.value());
   
    // Display preferences

    hlda.setTopicDisplay(showTopicsInterval.value(), topWords.value());
    hlda.setProgressDisplay(showProgress.value());

    // Initialize random number generator

    Randoms random = null;
    if (randomSeed.value() == 0) {
      random = new Randoms();
    }
    else {
      random = new Randoms(randomSeed.value());
    }

    // Initialize and start the sampler

    hlda.initialize(instances, testing, numLevels.value(), random);
    hlda.estimate(numIterations.value());
   
    // Output results

    if (stateFile.value() != null) {
      hlda.printState(new PrintWriter(stateFile.value()));
    }

    if (testing != null) {
      double empiricalLikelihood = hlda.empiricalLikelihood(1000, testing);
      System.out.println("Empirical likelihood: " + empiricalLikelihood);
    }
   
  }
View Full Code Here

TOP

Related Classes of cc.mallet.topics.HierarchicalLDA

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.