Skip to content

Commit 0972b62

Browse files
baishuopwendell
authored andcommitted
Update GradientDescentSuite.scala
use more faster way to construct an array Author: baishuo(白硕) <[email protected]> Closes #588 from baishuo/master and squashes the following commits: 45b95fb [baishuo(白硕)] Update GradientDescentSuite.scala c03b61c [baishuo(白硕)] Update GradientDescentSuite.scala b666d27 [baishuo(白硕)] Update GradientDescentSuite.scala (cherry picked from commit 0c19bb1) Signed-off-by: Patrick Wendell <[email protected]>
1 parent bb90e87 commit 0972b62

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 -> Vectors.dense(1.0 +: features.toArray)
8585
}
8686

8787
val dataRDD = sc.parallelize(data, 2).cache()
88-
val initialWeightsWithIntercept = Vectors.dense(1.0, initialWeights: _*)
88+
val initialWeightsWithIntercept = Vectors.dense(1.0 +: initialWeights.toArray)
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 -> Vectors.dense(1.0 +: features.toArray)
115115
}
116116

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

0 commit comments

Comments
 (0)