本文整理汇总了Java中org.apache.mahout.math.Vector.clone方法的典型用法代码示例。如果您正苦于以下问题:Java Vector.clone方法的具体用法?Java Vector.clone怎么用?Java Vector.clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mahout.math.Vector
的用法示例。
在下文中一共展示了Vector.clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: observe
import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
@Override
public void observe(Vector x, double weight) {
double temp = weight + sumWeight;
Vector q;
if (mean == null) {
mean = x.like();
q = x.clone();
} else {
q = x.minus(mean);
}
Vector r = q.times(weight).divide(temp);
if (s == null) {
s = q.times(sumWeight).times(r);
} else {
s = s.plus(q.times(sumWeight).times(r));
}
mean = mean.plus(r);
sumWeight = temp;
variance = s.divide(sumWeight - 1); // # if sample is the population, omit -1
}
示例2: reduce
import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
@Override
protected void reduce(WritableComparable<?> key, Iterable<VectorWritable> values, Context context)
throws IOException, InterruptedException {
Iterator<VectorWritable> it = values.iterator();
if (!it.hasNext()) {
return;
}
Vector value = it.next().get();
Vector vector = value.clone();
if (maxDf > -1) {
Iterator<Vector.Element> it1 = value.iterateNonZero();
while (it1.hasNext()) {
Vector.Element e = it1.next();
if (!dictionary.containsKey(e.index())) {
vector.setQuick(e.index(), 0.0);
continue;
}
long df = dictionary.get(e.index());
if (df > maxDf) {
vector.setQuick(e.index(), 0.0);
}
}
}
VectorWritable vectorWritable = new VectorWritable(vector);
context.write(key, vectorWritable);
}