problem solved.

The package org.apache.spark.api.java.function.Function was missing.

Thanks.
Carlo

On 3 Aug 2016, at 12:14, Carlo.Allocca 
<carlo.allo...@open.ac.uk<mailto:carlo.allo...@open.ac.uk>> wrote:

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:

<Screen Shot 2016-08-03 at 12.08.53.png><Screen Shot 2016-08-03 at 12.09.05.png>


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.

Reply via email to