@@ -21,7 +21,7 @@ import com.github.fommil.netlib.BLAS
21
21
22
22
import org .apache .spark .{SparkException , SparkFunSuite }
23
23
import org .apache .spark .ml .classification .LinearSVCSuite .generateSVMInput
24
- import org .apache .spark .ml .feature .LabeledPoint
24
+ import org .apache .spark .ml .feature .{ Instance , LabeledPoint }
25
25
import org .apache .spark .ml .linalg .{Vector , Vectors }
26
26
import org .apache .spark .ml .param .ParamsSuite
27
27
import org .apache .spark .ml .regression .DecisionTreeRegressionModel
@@ -401,8 +401,10 @@ class GBTClassifierSuite extends MLTest with DefaultReadWriteTest {
401
401
model3.trees.take(2 ), model3.treeWeights.take(2 ), model3.numFeatures, model3.numClasses)
402
402
403
403
val evalArr = model3.evaluateEachIteration(validationData.toDF)
404
- val remappedValidationData = validationData.map(
405
- x => LabeledPoint ((x.label * 2 ) - 1 , x.features).toInstance)
404
+ val remappedValidationData = validationData.map {
405
+ case LabeledPoint (label, features) =>
406
+ Instance (label * 2 - 1 , 1.0 , features)
407
+ }
406
408
val lossErr1 = GradientBoostedTrees .computeError(remappedValidationData,
407
409
model1.trees, model1.treeWeights, model1.getOldLossType)
408
410
val lossErr2 = GradientBoostedTrees .computeError(remappedValidationData,
@@ -437,8 +439,10 @@ class GBTClassifierSuite extends MLTest with DefaultReadWriteTest {
437
439
assert(modelWithValidation.numTrees < numIter)
438
440
439
441
val (errorWithoutValidation, errorWithValidation) = {
440
- val remappedRdd = validationData.map(x =>
441
- LabeledPoint (2 * x.label - 1 , x.features).toInstance)
442
+ val remappedRdd = validationData.map {
443
+ case LabeledPoint (label, features) =>
444
+ Instance (label * 2 - 1 , 1.0 , features)
445
+ }
442
446
(GradientBoostedTrees .computeError(remappedRdd, modelWithoutValidation.trees,
443
447
modelWithoutValidation.treeWeights, modelWithoutValidation.getOldLossType),
444
448
GradientBoostedTrees .computeError(remappedRdd, modelWithValidation.trees,
0 commit comments