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

    https://github.com/apache/spark/pull/8631#discussion_r39812144
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/regression/LinearRegression.scala ---
    @@ -123,30 +132,41 @@ class LinearRegression(override val uid: String)
       def setTol(value: Double): this.type = set(tol, value)
       setDefault(tol -> 1E-6)
     
    +  /**
    +   * 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 protected def train(dataset: DataFrame): LinearRegressionModel 
= {
         // Extract columns from data.  If dataset is persisted, do not persist 
instances.
    -    val instances = extractLabeledPoints(dataset).map {
    -      case LabeledPoint(label: Double, features: Vector) => (label, 
features)
    +    val w = if ($(weightCol).isEmpty) lit(1.0) else col($(weightCol))
    +    val instances: RDD[Instance] = dataset.select(col($(labelCol)), w, 
col($(featuresCol))).map {
    +      case Row(label: Double, weight: Double, features: Vector) =>
    +        Instance(label, weight, features)
         }
    +
         val handlePersistence = dataset.rdd.getStorageLevel == 
StorageLevel.NONE
         if (handlePersistence) instances.persist(StorageLevel.MEMORY_AND_DISK)
     
    -    val (summarizer, statCounter) = instances.treeAggregate(
    -      (new MultivariateOnlineSummarizer, new StatCounter))(
    -        seqOp = (c, v) => (c, v) match {
    -          case ((summarizer: MultivariateOnlineSummarizer, statCounter: 
StatCounter),
    -          (label: Double, features: Vector)) =>
    -            (summarizer.add(features), statCounter.merge(label))
    -      },
    -        combOp = (c1, c2) => (c1, c2) match {
    -          case ((summarizer1: MultivariateOnlineSummarizer, statCounter1: 
StatCounter),
    -          (summarizer2: MultivariateOnlineSummarizer, statCounter2: 
StatCounter)) =>
    -            (summarizer1.merge(summarizer2), 
statCounter1.merge(statCounter2))
    -      })
    -
    -    val numFeatures = summarizer.mean.size
    -    val yMean = statCounter.mean
    -    val yStd = math.sqrt(statCounter.variance)
    +    val (featuresSummarizer, ySummarizer) = {
    +      val seqOp = (c: (MultivariateOnlineSummarizer, 
MultivariateOnlineSummarizer),
    +                   instance: Instance) =>
    --- End diff --
    
    indentation. see LoR for example.


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