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

    https://github.com/apache/spark/pull/5249#discussion_r27463808
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/classification/LogisticRegression.scala
 ---
    @@ -145,13 +135,20 @@ class LogisticRegressionModel (
            */
           var bestClass = 0
           var maxMargin = 0.0
    -      var i = 0
    -      while(i < margins.size) {
    -        if (margins(i) > maxMargin) {
    -          maxMargin = margins(i)
    +      val withBias = if (dataMatrix.size + 1 == dataWithBiasSize) true 
else false
    +      (0 until numClasses - 1).map { i =>
    +        var margin = 0.0
    +        dataMatrix.foreachActive { (index, value) =>
    +          if (value != 0.0) margin += value * weightsArray((i * 
dataWithBiasSize) + index)
    --- End diff --
    
    It's minor, but I wonder if this is faster without the branch. It wouldn't 
affect the result. Also if you're concerned with speed I think you can 
precompute `i * dataWithBiasSize` which is used many times.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to