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

    https://github.com/apache/spark/pull/7884#discussion_r39474414
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
 ---
    @@ -218,31 +228,48 @@ class LogisticRegression(override val uid: String)
     
       override def getThreshold: Double = super.getThreshold
     
    +  /**
    +   * Whether to over-/under-sample training instances according to the 
given weights in weightCol.
    +   * If empty, all instances are treated equally (weight 1.0).
    +   * Default is empty, so all instances have weight one.
    +   * @group setParam
    +   */
    +  def setWeightCol(value: String): this.type = set(weightCol, value)
    +  setDefault(weightCol -> "")
    +
       override def setThresholds(value: Array[Double]): this.type = 
super.setThresholds(value)
     
       override def getThresholds: Array[Double] = super.getThresholds
     
       override protected def train(dataset: DataFrame): 
LogisticRegressionModel = {
         // Extract columns from data.  If dataset is persisted, do not persist 
oldDataset.
    -    val instances = extractLabeledPoints(dataset).map {
    -      case LabeledPoint(label: Double, features: Vector) => (label, 
features)
    +    val instances: RDD[Instance] = if ($(weightCol).isEmpty) {
    --- End diff --
    
    From my previous comment, using `val w = if ($(weightCol).isEmpty) lit(1.0) 
else col($(weightCol))` could simplify this block.


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