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

    https://github.com/apache/spark/pull/10788#discussion_r49961964
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
 ---
    @@ -247,10 +247,31 @@ class LogisticRegression @Since("1.2.0") (
       @Since("1.5.0")
       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.
    +  private var optInitialCoefficients: Option[Vector] = None
    +  /** @group setParam */
    +  private[spark] def setInitialWeights(value: Vector): this.type = {
    +    this.optInitialCoefficients = Some(value)
    +    this
    +  }
    +
    +  /**
    +   * Validate the initial weights, return an Option, if not the expected 
size return None
    +   * and log a warning.
    +   */
    +  private def validateWeights(vectorOpt: Option[Vector], numFeatures: 
Int): Option[Vector] = {
    +    vectorOpt.flatMap(vec =>
    +      if (vec.size == numFeatures) {
    +        Some(vec)
    +      } else {
    +        logWarning(
    +          s"""Initial weights provided (${vec})did not match the expected 
size ${numFeatures}""")
    +        None
    +      })
    +  }
    +
    +  override protected[spark] def train(dataset: DataFrame): 
LogisticRegressionModel = {
         val w = if ($(weightCol).isEmpty) lit(1.0) else col($(weightCol))
    -    val instances: RDD[Instance] = dataset.select(col($(labelCol)), w, 
col($(featuresCol))).map {
    +    val instances = dataset.select(col($(labelCol)), w, 
col($(featuresCol))).map {
    --- End diff --
    
    why this line is changed?


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