Github user yanboliang commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18315#discussion_r133665834
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/classification/LinearSVC.scala ---
    @@ -219,8 +219,17 @@ class LinearSVC @Since("2.2.0") (
           val featuresStd = summarizer.variance.toArray.map(math.sqrt)
           val regParamL2 = $(regParam)
           val bcFeaturesStd = instances.context.broadcast(featuresStd)
    -      val costFun = new LinearSVCCostFun(instances, $(fitIntercept),
    -        $(standardization), bcFeaturesStd, regParamL2, $(aggregationDepth))
    +      val regularization = if (regParamL2 != 0.0) {
    +        val shouldApply = (idx: Int) => idx >= 0 && idx < numFeatures
    +        Some(new L2Regularization(regParamL2, shouldApply,
    +          if ($(standardization)) None else Some(featuresStd)))
    --- End diff --
    
    Minor: The third argument ```applyFeaturesStd``` is a function rather than 
an array in semantics:
    ```
    private[ml] class L2Regularization(
        override val regParam: Double,
        shouldApply: Int => Boolean,
        applyFeaturesStd: Option[Int => Double]) extends 
DifferentiableRegularization[Vector]
    ```
    In LiR and LoR, we use a function:
    ```
    val getFeaturesStd = (j: Int) => if (j >= 0 && j < numFeatures) 
featuresStd(j) else 0.0
    ```
    I think either is ok, but it's better to keep consistent with other 
algorithms. We can change here to use function or change the third argument of 
```L2Regularization``` to ```Option[Array[Double]]```. I'm prefer the former 
way, what's your opinion? Thanks.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to