Skip to content

Commit

Permalink
Update GradientDescentSuite.scala
Browse files Browse the repository at this point in the history
use more faster way to construct an array

Author: baishuo(白硕) <vc_java@hotmail.com>

Closes apache#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 <pwendell@gmail.com>
  • Loading branch information
baishuo authored and pwendell committed May 7, 2014
1 parent bb90e87 commit 0972b62
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ class GradientDescentSuite extends FunSuite with LocalSparkContext with ShouldMa
// Add a extra variable consisting of all 1.0's for the intercept.
val testData = GradientDescentSuite.generateGDInput(A, B, nPoints, 42)
val data = testData.map { case LabeledPoint(label, features) =>
label -> Vectors.dense(1.0, features.toArray: _*)
label -> Vectors.dense(1.0 +: features.toArray)
}

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

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

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

0 comments on commit 0972b62

Please sign in to comment.