如何设置LabeledPointData的编码器,它是Double,Vector of Vectors的组合。如何设置编码器来创建DataFrame?
public static Dataset<LabeledPoint> convertRDDStringToLabeledPoint(Dataset<String> data,String delimiter) {
Dataset<LabeledPoint> labeledPointData = data.map(
(data1)->{
String splitter[] = data1.split(delimiter);
double[] arr = new double[splitter.length - 1];
IntStream.range(0,arr.length).forEach(i->arr[i]=Double.parseDouble(splitter[i+1]));
return new LabeledPoint(Double.parseDouble(splitter[0]), Vectors.dense(arr));
},Encoders.???);
return labeledPointData;
}
答案 0 :(得分:1)
LabeledPoint
是Scala中的案例类,因此我认为它是Encoders.product[LabeledPoint]
。
(我不知道如何用Java编写)