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
  • Loading branch information
baishuo committed Apr 29, 2014
1 parent 9a1184a commit b666d27
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 -> (1.0 +: features)
}

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

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 -> (1.0 +: features)
}

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

0 comments on commit b666d27

Please sign in to comment.