Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix tests
  • Loading branch information
mengxr committed Aug 16, 2014
commit e3efbb100b7593b040f1809765eca8bab363392f
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,9 @@ class LogisticRegressionClusterSuite extends FunSuite with LocalClusterSparkCont
}.cache()
// If we serialize data directly in the task closure, the size of the serialized task would be
// greater than 1MB and hence Spark would throw an error.
val model =
(new LogisticRegressionWithLBFGS().setIntercept(true).setNumIterations(2)).run(points)
val lr = new LogisticRegressionWithLBFGS().setIntercept(true)
lr.optimizer.setNumIterations(2)
val model = lr.run(points)

val predictions = model.predict(points.map(_.features))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ class LBFGSSuite extends FunSuite with LocalSparkContext with Matchers {

val initialWeightsWithIntercept = Vectors.dense(1.0 +: initialWeights.toArray)
val convergenceTol = 1e-12
val maxNumIterations = 10
val numIterations = 10

val (_, loss) = LBFGS.runLBFGS(
dataRDD,
gradient,
simpleUpdater,
numCorrections,
convergenceTol,
maxNumIterations,
numIterations,
regParam,
initialWeightsWithIntercept)

Expand Down Expand Up @@ -99,15 +99,15 @@ class LBFGSSuite extends FunSuite with LocalSparkContext with Matchers {
// Prepare another non-zero weights to compare the loss in the first iteration.
val initialWeightsWithIntercept = Vectors.dense(0.3, 0.12)
val convergenceTol = 1e-12
val maxNumIterations = 10
val numIterations = 10

val (weightLBFGS, lossLBFGS) = LBFGS.runLBFGS(
dataRDD,
gradient,
squaredL2Updater,
numCorrections,
convergenceTol,
maxNumIterations,
numIterations,
regParam,
initialWeightsWithIntercept)

Expand Down Expand Up @@ -140,10 +140,10 @@ class LBFGSSuite extends FunSuite with LocalSparkContext with Matchers {

/**
* For the first run, we set the convergenceTol to 0.0, so that the algorithm will
* run up to the maxNumIterations which is 8 here.
* run up to the numIterations which is 8 here.
*/
val initialWeightsWithIntercept = Vectors.dense(0.0, 0.0)
val maxNumIterations = 8
val numIterations = 8
var convergenceTol = 0.0

val (_, lossLBFGS1) = LBFGS.runLBFGS(
Expand All @@ -152,7 +152,7 @@ class LBFGSSuite extends FunSuite with LocalSparkContext with Matchers {
squaredL2Updater,
numCorrections,
convergenceTol,
maxNumIterations,
numIterations,
regParam,
initialWeightsWithIntercept)

Expand All @@ -167,7 +167,7 @@ class LBFGSSuite extends FunSuite with LocalSparkContext with Matchers {
squaredL2Updater,
numCorrections,
convergenceTol,
maxNumIterations,
numIterations,
regParam,
initialWeightsWithIntercept)

Expand All @@ -182,7 +182,7 @@ class LBFGSSuite extends FunSuite with LocalSparkContext with Matchers {
squaredL2Updater,
numCorrections,
convergenceTol,
maxNumIterations,
numIterations,
regParam,
initialWeightsWithIntercept)

Expand All @@ -200,12 +200,12 @@ class LBFGSSuite extends FunSuite with LocalSparkContext with Matchers {
// Prepare another non-zero weights to compare the loss in the first iteration.
val initialWeightsWithIntercept = Vectors.dense(0.3, 0.12)
val convergenceTol = 1e-12
val maxNumIterations = 10
val numIterations = 10

val lbfgsOptimizer = new LBFGS(gradient, squaredL2Updater)
.setNumCorrections(numCorrections)
.setConvergenceTol(convergenceTol)
.setMaxNumIterations(maxNumIterations)
.setNumIterations(numIterations)
.setRegParam(regParam)

val weightLBFGS = lbfgsOptimizer.optimize(dataRDD, initialWeightsWithIntercept)
Expand Down Expand Up @@ -241,7 +241,7 @@ class LBFGSClusterSuite extends FunSuite with LocalClusterSparkContext {
val lbfgs = new LBFGS(new LogisticGradient, new SquaredL2Updater)
.setNumCorrections(1)
.setConvergenceTol(1e-12)
.setMaxNumIterations(1)
.setNumIterations(1)
.setRegParam(1.0)
val random = new Random(0)
// If we serialize data directly in the task closure, the size of the serialized task would be
Expand Down