当前位置: 首页>>代码示例>>Java>>正文


Java VectorIterable类代码示例

本文整理汇总了Java中org.apache.mahout.math.VectorIterable的典型用法代码示例。如果您正苦于以下问题:Java VectorIterable类的具体用法?Java VectorIterable怎么用?Java VectorIterable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VectorIterable类属于org.apache.mahout.math包,在下文中一共展示了VectorIterable类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculatePerplexity

import org.apache.mahout.math.VectorIterable; //导入依赖的package包/类
public double calculatePerplexity(VectorIterable matrix, VectorIterable docTopicCounts,
    double testFraction) {
  Iterator<MatrixSlice> docIterator = matrix.iterator();
  Iterator<MatrixSlice> docTopicIterator = docTopicCounts.iterator();
  double perplexity = 0;
  double matrixNorm = 0;
  while (docIterator.hasNext() && docTopicIterator.hasNext()) {
    MatrixSlice docSlice = docIterator.next();
    MatrixSlice topicSlice = docTopicIterator.next();
    int docId = docSlice.index();
    Vector document = docSlice.vector();
    Vector topicDist = topicSlice.vector();
    if (testFraction == 0 || docId % (1/testFraction) == 0) {
      trainSync(document, topicDist, false, 10);
      perplexity += readModel.perplexity(document, topicDist);
      matrixNorm += document.norm(1);
    }
  }
  return perplexity / matrixNorm;
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:21,代码来源:ModelTrainer.java

示例2: sample

import org.apache.mahout.math.VectorIterable; //导入依赖的package包/类
static <M extends VectorIterable> Matrix sample(M bigMatrix,
    Matrix sampleMatrix) {
  log.info("Sampling a " + bigMatrix.numRows() + "x" + bigMatrix.numCols()
      + " into a " + sampleMatrix.numRows() + "x" + sampleMatrix.numCols());
  int row = 0;
  Iterator<MatrixSlice> sliceIterator = bigMatrix.iterateAll();
  while (sliceIterator.hasNext() && row < sampleMatrix.numRows()) {
    MatrixSlice slice = sliceIterator.next();
    if (!PCACommon.pass(SAMPLE_RATE)) {
      sampleMatrix.viewRow(row).assign(slice.vector());
      row++;
    }
  }
  return sampleMatrix;
}
 
开发者ID:SiddharthMalhotra,项目名称:sPCA,代码行数:16,代码来源:SPCADriver.java

示例3: train

import org.apache.mahout.math.VectorIterable; //导入依赖的package包/类
public void train(VectorIterable matrix, VectorIterable docTopicCounts) {
  train(matrix, docTopicCounts, 1);
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:4,代码来源:ModelTrainer.java


注:本文中的org.apache.mahout.math.VectorIterable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。