これは私が距離を計算するためにorg.apache.commons.math3.ml.distance.EuclideanDistance
を使用トリックここ
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
final DataSet<double[]> a = env.fromElements(new double[]{0.1, 0.3, 0.8});
final DataSet<double[]> b = env.fromElements(new double[]{0.2, 0.4, 0.7});
a.cross(b).map(new MapFunction<Tuple2<double[],double[]>, Double>() {
final EuclideanDistance distance = new EuclideanDistance();
@Override
public Double map(Tuple2<double[], double[]> value) throws Exception {
return distance.compute(value.f0, value.f1);
}
})
.print(); // start execution and output result to STDOUT
を行う必要があります。