Skip to content

Commit b666d27

Browse files
committed
Update GradientDescentSuite.scala
use more faster way to construct an array
1 parent 9a1184a commit b666d27

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mllib/src/test/scala/org/apache/spark/mllib/optimization/GradientDescentSuite.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ class GradientDescentSuite extends FunSuite with LocalSparkContext with ShouldMa
8181
// Add a extra variable consisting of all 1.0's for the intercept.
8282
val testData = GradientDescentSuite.generateGDInput(A, B, nPoints, 42)
8383
val data = testData.map { case LabeledPoint(label, features) =>
84-
label -> Vectors.dense(1.0, features.toArray: _*)
84+
label -> (1.0 +: features)
8585
}
8686

8787
val dataRDD = sc.parallelize(data, 2).cache()
88-
val initialWeightsWithIntercept = Vectors.dense(1.0, initialWeights: _*)
88+
val initialWeightsWithIntercept = 1.0 +: initialWeights
8989

9090
val (_, loss) = GradientDescent.runMiniBatchSGD(
9191
dataRDD,
@@ -111,7 +111,7 @@ class GradientDescentSuite extends FunSuite with LocalSparkContext with ShouldMa
111111
// Add a extra variable consisting of all 1.0's for the intercept.
112112
val testData = GradientDescentSuite.generateGDInput(2.0, -1.5, 10000, 42)
113113
val data = testData.map { case LabeledPoint(label, features) =>
114-
label -> Vectors.dense(1.0, features.toArray: _*)
114+
label -> (1.0 +: features)
115115
}
116116

117117
val dataRDD = sc.parallelize(data, 2).cache()

0 commit comments

Comments
 (0)