本文整理了Java中org.apache.mahout.math.random.WeightedThing
类的一些代码示例,展示了WeightedThing
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WeightedThing
类的具体详情如下:
包路径:org.apache.mahout.math.random.WeightedThing
类名称:WeightedThing
[英]Handy for creating multinomial distributions of things.
[中]便于创建事物的多项式分布。
代码示例来源:origin: apache/mahout
public Multinomial(Iterable<WeightedThing<T>> things) {
this();
for (WeightedThing<T> thing : things) {
add(thing.getValue(), thing.getWeight());
}
}
代码示例来源:origin: apache/mahout
double sample(double u) {
if (u < limit) {
List<WeightedThing<Integer>> steps = Lists.newArrayList();
limit = 1;
int i = 0;
while (u / 20 < limit) {
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<Vector> removeHash(WeightedThing<Vector> input) {
return new WeightedThing<Vector>(((HashedVector) input.getValue()).getVector(), input.getWeight());
}
代码示例来源:origin: org.apache.mahout/mahout-mr
List<WeightedThing<Vector>> currProjections = scalarProjections.get(i);
int middle = Collections.binarySearch(currProjections,
new WeightedThing<Vector>(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<Vector> 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<Vector> toRemove = searchFirst(vector, false);
if (toRemove.getWeight() < epsilon) {
Iterator<? extends Vector> basisVectors = basisMatrix.iterator();
for (TreeMultiset<WeightedThing<Vector>> projection : scalarProjections) {
if (!projection.remove(new WeightedThing<Vector>(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 < numProjections; ++i) {
scalarProjections.get(i).add(new WeightedThing<Vector>(pending, projection.get(i)));
List<WeightedThing<Vector>> currProjections = scalarProjections.get(i);
for (WeightedThing<Vector> v : currProjections) {
if (v.getValue() == null) {
v.setWeight(Double.POSITIVE_INFINITY);
代码示例来源:origin: org.apache.mahout/mahout-core
@Override
protected boolean lessThan(WeightedThing<Vector> a, WeightedThing<Vector> b) {
return a.getWeight() > b.getWeight();
}
};
代码示例来源:origin: org.apache.mahout/mahout-mr
protected static WeightedThing<Vector> removeHash(WeightedThing<Vector> input) {
return new WeightedThing<>(((HashedVector) input.getValue()).getVector(), input.getWeight());
}
代码示例来源:origin: org.apache.mahout/mahout-core
List<WeightedThing<Vector>> currProjections = scalarProjections.get(i);
int middle = Collections.binarySearch(currProjections,
new WeightedThing<Vector>(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<Vector>(candidate, distanceMeasure.distance(candidate, query)));
代码示例来源:origin: org.apache.mahout/mahout-core
@Override
protected Vector computeNext() {
do {
if (!data.hasNext()) {
return endOfData();
}
WeightedThing<Vector> 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<Vector> toRemove = searchFirst(vector, false);
if (toRemove.getWeight() < epsilon) {
Iterator<? extends Vector> basisVectors = basisMatrix.iterator();
for (TreeMultiset<WeightedThing<Vector>> projection : scalarProjections) {
if (!projection.remove(new WeightedThing<Vector>(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 < numProjections; ++i) {
scalarProjections.get(i).add(new WeightedThing<Vector>(pending, projection.get(i)));
List<WeightedThing<Vector>> currProjections = scalarProjections.get(i);
for (WeightedThing<Vector> v : currProjections) {
if (v.getValue() == null) {
v.setWeight(Double.POSITIVE_INFINITY);
代码示例来源:origin: org.apache.mahout/mahout-mr
@Override
protected boolean lessThan(WeightedThing<Vector> a, WeightedThing<Vector> b) {
return a.getWeight() > b.getWeight();
}
};
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
protected static WeightedThing<Vector> removeHash(WeightedThing<Vector> input) {
return new WeightedThing<Vector>(((HashedVector) input.getValue()).getVector(), input.getWeight());
}
代码示例来源:origin: org.apache.mahout/mahout-math
public Multinomial(Iterable<WeightedThing<T>> things) {
this();
for (WeightedThing<T> thing : things) {
add(thing.getValue(), thing.getWeight());
}
}
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
List<WeightedThing<Vector>> currProjections = scalarProjections.get(i);
int middle = Collections.binarySearch(currProjections,
new WeightedThing<Vector>(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<Vector>(candidate, distanceMeasure.distance(candidate, query)));
代码示例来源:origin: org.apache.mahout/mahout-mr
@Override
protected Vector computeNext() {
do {
if (!data.hasNext()) {
return endOfData();
}
WeightedThing<Vector> 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<Vector> toRemove = searchFirst(vector, false);
if (toRemove.getWeight() < epsilon) {
Iterator<? extends Vector> basisVectors = basisMatrix.iterator();
for (TreeMultiset<WeightedThing<Vector>> 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 < numProjections; ++i) {
scalarProjections.get(i).add(new WeightedThing<>(pending, projection.get(i)));
List<WeightedThing<Vector>> currProjections = scalarProjections.get(i);
for (WeightedThing<Vector> v : currProjections) {
if (v.getValue() == null) {
v.setWeight(Double.POSITIVE_INFINITY);
内容来源于网络,如有侵权,请联系作者删除!