Skip to content

Commit

Permalink
[SPARK-18901][FOLLOWUP][ML] Require in LR LogisticAggregator is redun…
Browse files Browse the repository at this point in the history
…dant

## What changes were proposed in this pull request?

This is a follow-up PR of apache#17478.

## How was this patch tested?

Existing tests

Author: wangmiao1981 <[email protected]>

Closes apache#17754 from wangmiao1981/followup.
  • Loading branch information
wangmiao1981 authored and yanboliang committed Apr 25, 2017
1 parent 0bc7a90 commit 387565c
Showing 2 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -458,9 +458,7 @@ private class LinearSVCAggregator(
*/
def add(instance: Instance): this.type = {
instance match { case Instance(label, weight, features) =>
require(weight >= 0.0, s"instance weight, $weight has to be >= 0.0")
require(numFeatures == features.size, s"Dimensions mismatch when adding new instance." +
s" Expecting $numFeatures but got ${features.size}.")

if (weight == 0.0) return this
val localFeaturesStd = bcFeaturesStd.value
val localCoefficients = coefficientsArray
@@ -512,6 +510,7 @@ private class LinearSVCAggregator(
* @return This LinearSVCAggregator object.
*/
def merge(other: LinearSVCAggregator): this.type = {

if (other.weightSum != 0.0) {
weightSum += other.weightSum
lossSum += other.lossSum
Original file line number Diff line number Diff line change
@@ -971,9 +971,6 @@ private class LeastSquaresAggregator(
*/
def add(instance: Instance): this.type = {
instance match { case Instance(label, weight, features) =>
require(dim == features.size, s"Dimensions mismatch when adding new sample." +
s" Expecting $dim but got ${features.size}.")
require(weight >= 0.0, s"instance weight, $weight has to be >= 0.0")

if (weight == 0.0) return this

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

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

0 comments on commit 387565c

Please sign in to comment.