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


Java Element.get方法代码示例

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


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

示例1: nextVector

import org.apache.mahout.math.Vector.Element; //导入方法依赖的package包/类
@Override
public MySparseVector nextVector() throws IOException {
   
    if(!vecIterator.hasNext()) return null;
    
    Pair<Text, VectorWritable> entry = vecIterator.next();
    
    String name = entry.getFirst().toString();
    VectorWritable mahoutVector = entry.getSecond();
    
    ArrayList<Integer> indices = new ArrayList();
    ArrayList<Double> values = new ArrayList();
    
    for(Element e: mahoutVector.get().all()){
        double value =e.get();
        if (value==0) continue;
        values.add(value);
        int index= e.index();
        indices.add(index);            
    }
    
    return new MySparseVector(indices, values);
    
}
 
开发者ID:project-asap,项目名称:IReS-Platform,代码行数:25,代码来源:MahoutInput.java

示例2: regularize

import org.apache.mahout.math.Vector.Element; //导入方法依赖的package包/类
private void regularize() {
	for (int i=0; i < this.numberOfAtoms; i++) {
		Vector atom = this.dictionaryMatrix.viewColumn(i);
		List<Integer> indicesToRemove = new ArrayList<Integer>();
		for (Element elem : atom.nonZeroes()) {
			double regularizedValue = elem.get() - (this.learningRate 
					* (elem.get() 
							* this.l2Penalty
							+ this.l1Penalty * Math.signum(elem.get())));
			if (regularizedValue == 0.0 || Math.abs(regularizedValue) < this.l1Penalty) {
				indicesToRemove.add(elem.index());
			} else {
				atom.setQuick(elem.index(), regularizedValue);
			}
		}
		for (int indexToRemove : indicesToRemove) {
			atom.setQuick(indexToRemove, 0.0);
		}
	}
}
 
开发者ID:maciejkula,项目名称:dictionarylearning,代码行数:21,代码来源:DictionaryLearner.java

示例3: computeProd2piR

import org.apache.mahout.math.Vector.Element; //导入方法依赖的package包/类
/**
 * Compute the product(r[i]*SQRT2PI) over all i. Note that the cluster Radius
 * corresponds to the Stdev of a Gaussian and the Center to its Mean.
 */
private void computeProd2piR() {
  zProd2piR = 1.0;
  for (Iterator<Element> it = getRadius().iterateNonZero(); it.hasNext();) {
    Element radius = it.next();
    zProd2piR *= radius.get() * UncommonDistributions.SQRT2PI;
  }
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:12,代码来源:GaussianCluster.java

示例4: sumXminusCdivRsquared

import org.apache.mahout.math.Vector.Element; //导入方法依赖的package包/类
/**
 * @param x
 *          a Vector
 * @return the zSum(((x[i]-c[i])/r[i])^2) over all i
 */
private double sumXminusCdivRsquared(Vector x) {
  double result = 0;
  for (Iterator<Element> it = getRadius().iterateNonZero(); it.hasNext();) {
    Element radiusElem = it.next();
    int index = radiusElem.index();
    double quotient = (x.get(index) - getCenter().get(index))
        / radiusElem.get();
    result += quotient * quotient;
  }
  return result;
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:17,代码来源:GaussianCluster.java

示例5: writeAllAboveThreshold

import org.apache.mahout.math.Vector.Element; //导入方法依赖的package包/类
private static void writeAllAboveThreshold(List<Cluster> clusterModels, Double clusterClassificationThreshold,
    SequenceFile.Writer writer, VectorWritable vw, Vector pdfPerCluster) throws IOException {
  Iterator<Element> iterateNonZero = pdfPerCluster.iterateNonZero();
  while (iterateNonZero.hasNext()) {
    Element pdf = iterateNonZero.next();
    if (pdf.get() >= clusterClassificationThreshold) {
      WeightedVectorWritable wvw = new WeightedVectorWritable(pdf.get(), vw.get());
      int clusterIndex = pdf.index();
      write(clusterModels, writer, wvw, clusterIndex);
    }
  }
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:13,代码来源:ClusterClassificationDriver.java

示例6: writeAllAboveThreshold

import org.apache.mahout.math.Vector.Element; //导入方法依赖的package包/类
private void writeAllAboveThreshold(VectorWritable vw, Context context,
    Vector pdfPerCluster) throws IOException, InterruptedException {
  Iterator<Element> iterateNonZero = pdfPerCluster.iterateNonZero();
  while (iterateNonZero.hasNext()) {
    Element pdf = iterateNonZero.next();
    if (pdf.get() >= threshold) {
      int clusterIndex = pdf.index();
      write(vw, context, clusterIndex, pdf.get());
    }
  }
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:12,代码来源:ClusterClassificationMapper.java

示例7: transposedDictionaryTimesDatapoint

import org.apache.mahout.math.Vector.Element; //导入方法依赖的package包/类
public static Vector transposedDictionaryTimesDatapoint(SparseColumnMatrix dictionary, Vector datapoint) {
	Vector output = new DenseVector(dictionary.numCols());
	for (int i=0; i < dictionary.numCols(); i++) {
		Vector row = dictionary.viewColumn(i);
		double value = 0.0;
		for (Element elem : row.nonZeroes()) {
			value = value + elem.get() * datapoint.get(elem.index());
		}
		output.setQuick(i, value);
	}
	return output;
}
 
开发者ID:maciejkula,项目名称:dictionarylearning,代码行数:13,代码来源:MathUtils.java

示例8: writeAllAboveThreshold

import org.apache.mahout.math.Vector.Element; //导入方法依赖的package包/类
private void writeAllAboveThreshold(WritableComparable<?> key, Context context,
    Vector pdfPerCluster) throws IOException, InterruptedException {
  for (Element pdf : pdfPerCluster.nonZeroes()) {
    if (pdf.get() >= threshold) {
      int clusterIndex = pdf.index();
      write(key, context, clusterIndex, pdf.get());
    }
  }
}
 
开发者ID:pgorecki,项目名称:visearch,代码行数:10,代码来源:ImageToTextMapper.java

示例9: writeAllAboveThreshold

import org.apache.mahout.math.Vector.Element; //导入方法依赖的package包/类
private static void writeAllAboveThreshold(List<Cluster> clusterModels,
		Double clusterClassificationThreshold, SequenceFile.Writer writer,
		Text key, Vector pdfPerCluster) throws IOException {
	for (Element pdf : pdfPerCluster.nonZeroes()) {
		if (pdf.get() >= clusterClassificationThreshold) {
			int clusterIndex = pdf.index();
			write(clusterModels, writer, key, clusterIndex);
			// nie ma sensu zapisywac wiecej niz 1, bo i tak nie zapisujemy
			// wagi
			break;
		}
	}
}
 
开发者ID:pgorecki,项目名称:visearch,代码行数:14,代码来源:ImageToTextDriver.java

示例10: compare

import org.apache.mahout.math.Vector.Element; //导入方法依赖的package包/类
@Override
public int compare(Element a, Element b) {
    return a.get() < b.get() ? 1 : a.get() == b.get() ? 0 : -1;
}
 
开发者ID:maciejkula,项目名称:dictionarylearning,代码行数:5,代码来源:EvaluationUtils.java

示例11: map

import org.apache.mahout.math.Vector.Element; //导入方法依赖的package包/类
@Override
protected void map(IntWritable key, VectorWritable value, Context context) throws IOException, InterruptedException
{
	int maxIndex = -1;

	Vector similarityMatrixRow = value.get();
	/* remove self similarity */

	similarityMatrixRow.set(key.get(), Double.NEGATIVE_INFINITY);

	//
	// determine maximum index
	//
	Iterator<Element> it = similarityMatrixRow.iterateNonZero();

	while (it.hasNext())
	{
		Element e = it.next();

		// e.index() // == item id

		if (e.index() > maxIndex)
		{
			maxIndex = e.index();
		}
	}

	// System.out.println(String.format("key: %d maxIndex: %d", key.get(), maxIndex));

	if (maxIndex > 0)
	{

		RecommendationElement[] itemBasedRecommendations = new RecommendationElement[maxIndex];

		for (int i = 0; i < maxIndex; i++)
		{
			Element element = similarityMatrixRow.getElement(i);

			double similarityValue = Double.NEGATIVE_INFINITY;

			if (element != null)
			{
				similarityValue = element.get();
			}

			itemBasedRecommendations[i] = new RecommendationElement(i, similarityValue);
		}

		Arrays.sort(itemBasedRecommendations, new SimilarityComparator());

		RecommendationElementArray array = new RecommendationElementArray(itemBasedRecommendations);

		context.write(new VarIntWritable(key.get()), array);

	}
}
 
开发者ID:beeldengeluid,项目名称:zieook,代码行数:57,代码来源:ItemBasedSortSimilaritiesMapper.java


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