Skip to content

Commit 387565c

Browse files
wangmiao1981yanboliang
authored andcommitted
[SPARK-18901][FOLLOWUP][ML] Require in LR LogisticAggregator is redundant
## What changes were proposed in this pull request? This is a follow-up PR of #17478. ## How was this patch tested? Existing tests Author: wangmiao1981 <[email protected]> Closes #17754 from wangmiao1981/followup.
1 parent 0bc7a90 commit 387565c

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

mllib/src/main/scala/org/apache/spark/ml/classification/LinearSVC.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,7 @@ private class LinearSVCAggregator(
458458
*/
459459
def add(instance: Instance): this.type = {
460460
instance match { case Instance(label, weight, features) =>
461-
require(weight >= 0.0, s"instance weight, $weight has to be >= 0.0")
462-
require(numFeatures == features.size, s"Dimensions mismatch when adding new instance." +
463-
s" Expecting $numFeatures but got ${features.size}.")
461+
464462
if (weight == 0.0) return this
465463
val localFeaturesStd = bcFeaturesStd.value
466464
val localCoefficients = coefficientsArray
@@ -512,6 +510,7 @@ private class LinearSVCAggregator(
512510
* @return This LinearSVCAggregator object.
513511
*/
514512
def merge(other: LinearSVCAggregator): this.type = {
513+
515514
if (other.weightSum != 0.0) {
516515
weightSum += other.weightSum
517516
lossSum += other.lossSum

mllib/src/main/scala/org/apache/spark/ml/regression/LinearRegression.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -971,9 +971,6 @@ private class LeastSquaresAggregator(
971971
*/
972972
def add(instance: Instance): this.type = {
973973
instance match { case Instance(label, weight, features) =>
974-
require(dim == features.size, s"Dimensions mismatch when adding new sample." +
975-
s" Expecting $dim but got ${features.size}.")
976-
require(weight >= 0.0, s"instance weight, $weight has to be >= 0.0")
977974

978975
if (weight == 0.0) return this
979976

@@ -1005,8 +1002,6 @@ private class LeastSquaresAggregator(
10051002
* @return This LeastSquaresAggregator object.
10061003
*/
10071004
def merge(other: LeastSquaresAggregator): this.type = {
1008-
require(dim == other.dim, s"Dimensions mismatch when merging with another " +
1009-
s"LeastSquaresAggregator. Expecting $dim but got ${other.dim}.")
10101005

10111006
if (other.weightSum != 0) {
10121007
totalCnt += other.totalCnt

0 commit comments

Comments
 (0)