Github user imatiach-msft commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16699#discussion_r98011972
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala
 ---
    @@ -263,17 +288,21 @@ class GeneralizedLinearRegression @Since("2.0.0") 
(@Since("2.0.0") override val
         }
     
         val w = if (!isDefined(weightCol) || $(weightCol).isEmpty) lit(1.0) 
else col($(weightCol))
    -    val instances: RDD[Instance] =
    -      dataset.select(col($(labelCol)), w, col($(featuresCol))).rdd.map {
    -        case Row(label: Double, weight: Double, features: Vector) =>
    -          Instance(label, weight, features)
    +    val off = if (!isDefined(offsetCol) || $(offsetCol).isEmpty) lit(0.0) 
else col($(offsetCol))
    +    val instances: RDD[OffsetInstance] =
    +      dataset.select(col($(labelCol)), w, off, 
col($(featuresCol))).rdd.map {
    +        case Row(label: Double, weight: Double, offset: Double, features: 
Vector) =>
    +          OffsetInstance(label, weight, offset, features)
           }
     
         val model = if (familyObj == Gaussian && linkObj == Identity) {
           // TODO: Make standardizeFeatures and standardizeLabel configurable.
    +      val wlsInstances: RDD[Instance] = instances.map { instance =>
    +        Instance(instance.label - instance.offset, instance.weight, 
instance.features)
    --- End diff --
    
    going over all OffsetInstance and converting again to Instance seems like 
it would be expensive and it would increase memory usage.  What do you think 
about the alternative of making OffsetInstance inherit from Instance - but then 
you would have to change Instance from a case class - and then just passing 
Instance to the fit below?  Is there anything else we could do here?


---
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