本文整理汇总了Java中cc.mallet.topics.ParallelTopicModel.estimate方法的典型用法代码示例。如果您正苦于以下问题:Java ParallelTopicModel.estimate方法的具体用法?Java ParallelTopicModel.estimate怎么用?Java ParallelTopicModel.estimate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cc.mallet.topics.ParallelTopicModel
的用法示例。
在下文中一共展示了ParallelTopicModel.estimate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: predictValuesProbs
import cc.mallet.topics.ParallelTopicModel; //导入方法依赖的package包/类
public void predictValuesProbs(boolean topicCreation) {
ParallelTopicModel LDA = new ParallelTopicModel(this.numTopics, ALPHA * this.numTopics, BETA); // TODO
LDA.addInstances(this.instances);
LDA.setNumThreads(1);
LDA.setNumIterations(NUM_ITERATIONS);
LDA.setRandomSeed(43);
try {
LDA.estimate();
} catch (Exception e) {
e.printStackTrace();
}
this.docList = getMaxTopicsByDocs(LDA, this.numTopics);
System.out.println("Fetched Doc-List");
this.topicList = !topicCreation ? getMaxTermsByTopics(LDA, MAX_TERMS) : null;
System.out.println("Fetched Topic-List");
}
示例2: predictValuesProbs
import cc.mallet.topics.ParallelTopicModel; //导入方法依赖的package包/类
/**
* What does this boolean value signify.
* @param topicCreation
*/
public void predictValuesProbs(boolean topicCreation) {
ParallelTopicModel LDA = new ParallelTopicModel(this.numTopics, ALPHA * this.numTopics, BETA); // TODO
LDA.addInstances(this.instances);
LDA.setNumThreads(1);
LDA.setNumIterations(NUM_ITERATIONS);
LDA.setRandomSeed(43);
try {
LDA.estimate();
} catch (Exception e) {
e.printStackTrace();
}
this.docList = getMaxTopicsByDocs(LDA, this.numTopics);
System.out.println("Fetched Doc-List");
this.topicList = !topicCreation ? getMaxTermsByTopics(LDA, MAX_TERMS) : null;
System.out.println("Fetched Topic-List");
}
示例3: predictValuesProbs
import cc.mallet.topics.ParallelTopicModel; //导入方法依赖的package包/类
public void predictValuesProbs() {
ParallelTopicModel LDA = new ParallelTopicModel(this.numTopics, ALPHA * this.numTopics, BETA); // TODO
LDA.addInstances(this.instances);
LDA.setNumThreads(1);
LDA.setNumIterations(NUM_ITERATIONS);
LDA.setRandomSeed(43);
try {
LDA.estimate();
} catch (Exception e) {
e.printStackTrace();
}
this.docList = getMaxTopicsByDocs(LDA, this.numTopics);
System.out.println("Fetched Doc-List");
this.topicList = getMaxTermsByTopics(LDA, MAX_TERMS);
System.out.println("Fetched Topic-List");
}
示例4: createLDAModel
import cc.mallet.topics.ParallelTopicModel; //导入方法依赖的package包/类
/**
* Creates the LDA model on the specified document corpus
* @param texts a list of documents
* @param numTopics the number of desired documents
* @param numIterations the number of LDA iterationss
* @return An LDA topic model
* @throws IOException
*/
private ParallelTopicModel createLDAModel(List<String> texts, int numTopics, int numIterations) throws IOException
{
InstanceList instanceList = createInstanceList(texts);
ParallelTopicModel model = new ParallelTopicModel(numTopics);
model.addInstances(instanceList);
model.setNumIterations(numIterations);
model.estimate();
return model;
}
示例5: createNewModel
import cc.mallet.topics.ParallelTopicModel; //导入方法依赖的package包/类
private ParallelTopicModel createNewModel() throws IOException {
InstanceList instanceList = createInstanceList(textList);
//int numTopics = instanceList.size() / 2;
ParallelTopicModel model = new ParallelTopicModel(numTopics);
System.out.println(" NUMBER OF TOPICS "+numTopics);
model.addInstances(instanceList);
//model.beta = this.beta;
model.setNumIterations(this.numIterations);
model.setOptimizeInterval(this.optimizeInterval);
model.setNumThreads(4);
if (loggingHandler!=null) model.logger.addHandler(loggingHandler);
model.estimate();
System.out.println("Model log likelihood: " + model.modelLogLikelihood());
return model;
}
示例6: estimate
import cc.mallet.topics.ParallelTopicModel; //导入方法依赖的package包/类
/**
* 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;
}