@@ -19,7 +19,7 @@ package org.apache.spark.ml.regression
19
19
20
20
import scala .util .Random
21
21
22
- import org .apache .spark .{ SparkConf , SparkFunSuite }
22
+ import org .apache .spark .SparkConf
23
23
import org .apache .spark .ml .classification .LogisticRegressionSuite ._
24
24
import org .apache .spark .ml .feature .{Instance , OffsetInstance }
25
25
import org .apache .spark .ml .feature .{LabeledPoint , RFormula }
@@ -28,7 +28,6 @@ import org.apache.spark.ml.param.{ParamMap, ParamsSuite}
28
28
import org .apache .spark .ml .util .{DefaultReadWriteTest , MLTest , MLTestingUtils }
29
29
import org .apache .spark .ml .util .TestingUtils ._
30
30
import org .apache .spark .mllib .random ._
31
- import org .apache .spark .mllib .util .MLlibTestSparkContext
32
31
import org .apache .spark .serializer .KryoSerializer
33
32
import org .apache .spark .sql .{DataFrame , Row }
34
33
import org .apache .spark .sql .functions ._
@@ -269,7 +268,7 @@ class GeneralizedLinearRegressionSuite extends MLTest with DefaultReadWriteTest
269
268
(" inverse" , datasetGaussianInverse))) {
270
269
for (fitIntercept <- Seq (false , true )) {
271
270
val trainer = new GeneralizedLinearRegression ().setFamily(" gaussian" ).setLink(link)
272
- .setFitIntercept(fitIntercept).setLinkPredictionCol(" linkPrediction" )
271
+ .setFitIntercept(fitIntercept).setLinkPredictionCol(" linkPrediction" ).setTol( 1e-3 )
273
272
val model = trainer.fit(dataset)
274
273
val actual = Vectors .dense(model.intercept, model.coefficients(0 ), model.coefficients(1 ))
275
274
assert(actual ~= expected(idx) absTol 1e-4 , " Model mismatch: GLM with gaussian family, " +
@@ -328,7 +327,7 @@ class GeneralizedLinearRegressionSuite extends MLTest with DefaultReadWriteTest
328
327
for (fitIntercept <- Seq (false , true );
329
328
regParam <- Seq (0.0 , 0.1 , 1.0 )) {
330
329
val trainer = new GeneralizedLinearRegression ().setFamily(" gaussian" )
331
- .setFitIntercept(fitIntercept).setRegParam(regParam)
330
+ .setFitIntercept(fitIntercept).setRegParam(regParam).setTol( 1e-3 )
332
331
val model = trainer.fit(datasetGaussianIdentity)
333
332
val actual = Vectors .dense(model.intercept, model.coefficients(0 ), model.coefficients(1 ))
334
333
assert(actual ~= expected(idx) absTol 1e-4 , " Model mismatch: GLM with gaussian family, " +
@@ -384,7 +383,7 @@ class GeneralizedLinearRegressionSuite extends MLTest with DefaultReadWriteTest
384
383
(" cloglog" , datasetBinomial))) {
385
384
for (fitIntercept <- Seq (false , true )) {
386
385
val trainer = new GeneralizedLinearRegression ().setFamily(" binomial" ).setLink(link)
387
- .setFitIntercept(fitIntercept).setLinkPredictionCol(" linkPrediction" )
386
+ .setFitIntercept(fitIntercept).setLinkPredictionCol(" linkPrediction" ).setTol( 1e-3 )
388
387
val model = trainer.fit(dataset)
389
388
val actual = Vectors .dense(model.intercept, model.coefficients(0 ), model.coefficients(1 ),
390
389
model.coefficients(2 ), model.coefficients(3 ))
@@ -457,7 +456,7 @@ class GeneralizedLinearRegressionSuite extends MLTest with DefaultReadWriteTest
457
456
(" sqrt" , datasetPoissonSqrt))) {
458
457
for (fitIntercept <- Seq (false , true )) {
459
458
val trainer = new GeneralizedLinearRegression ().setFamily(" poisson" ).setLink(link)
460
- .setFitIntercept(fitIntercept).setLinkPredictionCol(" linkPrediction" )
459
+ .setFitIntercept(fitIntercept).setLinkPredictionCol(" linkPrediction" ).setTol( 1e-3 )
461
460
val model = trainer.fit(dataset)
462
461
val actual = Vectors .dense(model.intercept, model.coefficients(0 ), model.coefficients(1 ))
463
462
assert(actual ~= expected(idx) absTol 1e-4 , " Model mismatch: GLM with poisson family, " +
@@ -515,7 +514,7 @@ class GeneralizedLinearRegressionSuite extends MLTest with DefaultReadWriteTest
515
514
val dataset = datasetPoissonLogWithZero
516
515
for (fitIntercept <- Seq (false , true )) {
517
516
val trainer = new GeneralizedLinearRegression ().setFamily(" poisson" ).setLink(link)
518
- .setFitIntercept(fitIntercept).setLinkPredictionCol(" linkPrediction" )
517
+ .setFitIntercept(fitIntercept).setLinkPredictionCol(" linkPrediction" ).setTol( 1e-3 )
519
518
val model = trainer.fit(dataset)
520
519
val actual = Vectors .dense(model.intercept, model.coefficients(0 ), model.coefficients(1 ))
521
520
assert(actual ~= expected(idx) absTol 1e-4 , " Model mismatch: GLM with poisson family, " +
@@ -573,7 +572,7 @@ class GeneralizedLinearRegressionSuite extends MLTest with DefaultReadWriteTest
573
572
(" identity" , datasetGammaIdentity), (" log" , datasetGammaLog))) {
574
573
for (fitIntercept <- Seq (false , true )) {
575
574
val trainer = new GeneralizedLinearRegression ().setFamily(" Gamma" ).setLink(link)
576
- .setFitIntercept(fitIntercept).setLinkPredictionCol(" linkPrediction" )
575
+ .setFitIntercept(fitIntercept).setLinkPredictionCol(" linkPrediction" ).setTol( 1e-3 )
577
576
val model = trainer.fit(dataset)
578
577
val actual = Vectors .dense(model.intercept, model.coefficients(0 ), model.coefficients(1 ))
579
578
assert(actual ~= expected(idx) absTol 1e-4 , " Model mismatch: GLM with gamma family, " +
@@ -659,7 +658,7 @@ class GeneralizedLinearRegressionSuite extends MLTest with DefaultReadWriteTest
659
658
variancePower <- Seq (1.6 , 2.5 )) {
660
659
val trainer = new GeneralizedLinearRegression ().setFamily(" tweedie" )
661
660
.setFitIntercept(fitIntercept).setLinkPredictionCol(" linkPrediction" )
662
- .setVariancePower(variancePower).setLinkPower(linkPower)
661
+ .setVariancePower(variancePower).setLinkPower(linkPower).setTol( 1e-4 )
663
662
val model = trainer.fit(datasetTweedie)
664
663
val actual = Vectors .dense(model.intercept, model.coefficients(0 ), model.coefficients(1 ))
665
664
assert(actual ~= expected(idx) absTol 1e-4 , " Model mismatch: GLM with tweedie family, " +
@@ -736,7 +735,7 @@ class GeneralizedLinearRegressionSuite extends MLTest with DefaultReadWriteTest
736
735
for (variancePower <- Seq (0.0 , 1.0 , 2.0 , 1.5 )) {
737
736
val trainer = new GeneralizedLinearRegression ().setFamily(" tweedie" )
738
737
.setFitIntercept(fitIntercept).setLinkPredictionCol(" linkPrediction" )
739
- .setVariancePower(variancePower)
738
+ .setVariancePower(variancePower).setTol( 1e-3 )
740
739
val model = trainer.fit(datasetTweedie)
741
740
val actual = Vectors .dense(model.intercept, model.coefficients(0 ), model.coefficients(1 ))
742
741
assert(actual ~= expected(idx) absTol 1e-4 , " Model mismatch: GLM with tweedie family, " +
0 commit comments