How to set Encoders for LabeledPointData which is combination of Double, Vectors of Double. How to set Encoders for creating 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;
}
LabeledPoint
is a case class in Scala so I think it'sEncoders.product[LabeledPoint]
.(I don't know how to write it in Java)