Skip to content
Snippets Groups Projects
Commit 6491cbf0 authored by junzhi lu's avatar junzhi lu Committed by Sean Owen
Browse files

Fix bug in JavaRegressionMetricsExample.

the original code cant visit the last element of the"parts" array.
so the v[v.length–1] always equals 0

## What changes were proposed in this pull request?
change the recycle range from (1 to parts.length-1) to (1 to parts.length)

## How was this patch tested?

debug it in eclipse (´〜`*) zzz.

Please review http://spark.apache.org/contributing.html before opening a pull request.

Author: junzhi lu <452756565@qq.com>

Closes #18237 from masterwugui/patch-1.
parent 03383955
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ public class JavaRegressionMetricsExample {
JavaRDD<LabeledPoint> parsedData = data.map(line -> {
String[] parts = line.split(" ");
double[] v = new double[parts.length - 1];
for (int i = 1; i < parts.length - 1; i++) {
for (int i = 1; i < parts.length; i++) {
v[i - 1] = Double.parseDouble(parts[i].split(":")[1]);
}
return new LabeledPoint(Double.parseDouble(parts[0]), Vectors.dense(v));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment