本文整理了Java中org.apache.mahout.math.random.WeightedThing
类的一些代码示例,展示了WeightedThing
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WeightedThing
类的具体详情如下:
包路径:org.apache.mahout.math.random.WeightedThing
类名称:WeightedThing
WeightedThing介绍
[英]Handy for creating multinomial distributions of things.
[中]便于创建事物的多项式分布。
代码示例
代码示例来源:origin: apache/mahout
public Multinomial(Iterable> things) {
this();
for (WeightedThing thing : things) {
add(thing.getValue(), thing.getWeight());
}
}
代码示例来源:origin: apache/mahout
double sample(double u) {
if (u List> steps = Lists.newArrayList();
limit = 1;
int i = 0;
while (u / 20 double pdf = pd.probability(i);
limit -= pdf;
steps.add(new WeightedThing<>(i, pdf));
i++;
}
steps.add(new WeightedThing<>(steps.size(), limit));
partial = new Multinomial<>(steps);
}
return partial.sample(u);
}
}
代码示例来源:origin: org.apache.mahout/mahout-core
protected static WeightedThing removeHash(WeightedThing input) {
return new WeightedThing(((HashedVector) input.getValue()).getVector(), input.getWeight());
}
代码示例来源:origin: org.apache.mahout/mahout-mr
List> currProjectiOns= scalarProjections.get(i);
int middle = Collections.binarySearch(currProjections,
new WeightedThing(projection.get(i)));
if (middle <0) {
middle = -(middle + 1);
if (currProjections.get(j).getValue() == null) {
continue;
candidates.add(currProjections.get(j).getValue());
Lists.newArrayListWithCapacity(candidates.size() + pendingAdditions.size());
for (Vector candidate : Iterables.concat(candidates, pendingAdditions)) {
top.add(new WeightedThing<>(candidate, distanceMeasure.distance(candidate, query)));
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
@Override
protected Vector computeNext() {
do {
if (!data.hasNext()) {
return endOfData();
}
WeightedThing next = data.next();
if (next.getValue() != null) {
return next.getValue();
}
} while (true);
}
};
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
@Override
public boolean remove(Vector vector, double epsilon) {
WeightedThing toRemove = searchFirst(vector, false);
if (toRemove.getWeight() Iterator extends Vector> basisVectors = basisMatrix.iterator();
for (TreeMultiset> projection : scalarProjections) {
if (!projection.remove(new WeightedThing(vector, vector.dot(basisVectors.next())))) {
throw new RuntimeException("Internal inconsistency in ProjectionSearch");
}
}
return true;
} else {
return false;
}
}
代码示例来源:origin: org.apache.mahout/mahout-core
Vector projection = basisMatrix.times(pending);
for (int i = 0; i scalarProjections.get(i).add(new WeightedThing(pending, projection.get(i)));
List> currProjectiOns= scalarProjections.get(i);
for (WeightedThing v : currProjections) {
if (v.getValue() == null) {
v.setWeight(Double.POSITIVE_INFINITY);
代码示例来源:origin: org.apache.mahout/mahout-core
@Override
protected boolean lessThan(WeightedThing a, WeightedThing b) {
return a.getWeight() > b.getWeight();
}
};
代码示例来源:origin: org.apache.mahout/mahout-mr
protected static WeightedThing removeHash(WeightedThing input) {
return new WeightedThing<>(((HashedVector) input.getValue()).getVector(), input.getWeight());
}
代码示例来源:origin: org.apache.mahout/mahout-core
List> currProjectiOns= scalarProjections.get(i);
int middle = Collections.binarySearch(currProjections,
new WeightedThing(projection.get(i)));
if (middle <0) {
middle = -(middle + 1);
if (currProjections.get(j).getValue() == null) {
continue;
candidates.add(currProjections.get(j).getValue());
Lists.newArrayListWithCapacity(candidates.size() + pendingAdditions.size());
for (Vector candidate : Iterables.concat(candidates, pendingAdditions)) {
top.add(new WeightedThing(candidate, distanceMeasure.distance(candidate, query)));
代码示例来源:origin: org.apache.mahout/mahout-core
@Override
protected Vector computeNext() {
do {
if (!data.hasNext()) {
return endOfData();
}
WeightedThing next = data.next();
if (next.getValue() != null) {
return next.getValue();
}
} while (true);
}
};
代码示例来源:origin: org.apache.mahout/mahout-core
@Override
public boolean remove(Vector vector, double epsilon) {
WeightedThing toRemove = searchFirst(vector, false);
if (toRemove.getWeight() Iterator extends Vector> basisVectors = basisMatrix.iterator();
for (TreeMultiset> projection : scalarProjections) {
if (!projection.remove(new WeightedThing(vector, vector.dot(basisVectors.next())))) {
throw new RuntimeException("Internal inconsistency in ProjectionSearch");
}
}
return true;
} else {
return false;
}
}
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
Vector projection = basisMatrix.times(pending);
for (int i = 0; i scalarProjections.get(i).add(new WeightedThing(pending, projection.get(i)));
List> currProjectiOns= scalarProjections.get(i);
for (WeightedThing v : currProjections) {
if (v.getValue() == null) {
v.setWeight(Double.POSITIVE_INFINITY);
代码示例来源:origin: org.apache.mahout/mahout-mr
@Override
protected boolean lessThan(WeightedThing a, WeightedThing b) {
return a.getWeight() > b.getWeight();
}
};
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
protected static WeightedThing removeHash(WeightedThing input) {
return new WeightedThing(((HashedVector) input.getValue()).getVector(), input.getWeight());
}
代码示例来源:origin: org.apache.mahout/mahout-math
public Multinomial(Iterable> things) {
this();
for (WeightedThing thing : things) {
add(thing.getValue(), thing.getWeight());
}
}
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
List> currProjectiOns= scalarProjections.get(i);
int middle = Collections.binarySearch(currProjections,
new WeightedThing(projection.get(i)));
if (middle <0) {
middle = -(middle + 1);
if (currProjections.get(j).getValue() == null) {
continue;
candidates.add(currProjections.get(j).getValue());
Lists.newArrayListWithCapacity(candidates.size() + pendingAdditions.size());
for (Vector candidate : Iterables.concat(candidates, pendingAdditions)) {
top.add(new WeightedThing(candidate, distanceMeasure.distance(candidate, query)));
代码示例来源:origin: org.apache.mahout/mahout-mr
@Override
protected Vector computeNext() {
do {
if (!data.hasNext()) {
return endOfData();
}
WeightedThing next = data.next();
if (next.getValue() != null) {
return next.getValue();
}
} while (true);
}
};
代码示例来源:origin: org.apache.mahout/mahout-mr
@Override
public boolean remove(Vector vector, double epsilon) {
WeightedThing toRemove = searchFirst(vector, false);
if (toRemove.getWeight() Iterator extends Vector> basisVectors = basisMatrix.iterator();
for (TreeMultiset> projection : scalarProjections) {
if (!projection.remove(new WeightedThing<>(vector, vector.dot(basisVectors.next())))) {
throw new RuntimeException("Internal inconsistency in ProjectionSearch");
}
}
return true;
} else {
return false;
}
}
代码示例来源:origin: org.apache.mahout/mahout-mr
Vector projection = basisMatrix.times(pending);
for (int i = 0; i scalarProjections.get(i).add(new WeightedThing<>(pending, projection.get(i)));
List> currProjectiOns= scalarProjections.get(i);
for (WeightedThing v : currProjections) {
if (v.getValue() == null) {
v.setWeight(Double.POSITIVE_INFINITY);