Hi All,
I am trying to convert a Dataset<Row> into JavaRDD<LabeledPoint> in order to
apply a linear regression.
I am using spark-core_2.10, version2.0.0 with Java 1.8.
My current approach is:
== Step 1: convert the Dataset<Row> into JavaRDD<Row>
JavaRDD<Row> dataPoints =modelDS.toJavaRDD();
== Step 2: convert JavaRDD<Row> into JavaRDD<LabeledPoint>
JavaRDD<LabeledPoint> dataLabeledPoints = dataPoints.map(new Function<Row,
LabeledPoint>() {
@Override
public LabeledPoint call(Row line) throws Exception {
String lineAsString=line.toString();
String[] fields =lineAsString.split("\t");
LabeledPoint labeledPoint = new
LabeledPoint(Integer.valueOf(fields[0]),
Vectors.dense(Double.valueOf(fields[1]),Double.valueOf(fields[2]));
return labeledPoint;
}
});
The have got two compile time errors:
[cid:[email protected]][cid:[email protected]]
Please, I would like to ask what I am doing wrong?
Any suggestion is very appreciated.
Thanks in advance.
Best,
Carlo
-- The Open University is incorporated by Royal Charter (RC 000391), an exempt
charity in England & Wales and a charity registered in Scotland (SC 038302).
The Open University is authorised and regulated by the Financial Conduct
Authority.