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

    https://github.com/apache/spark/pull/3099#discussion_r20115869
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
 ---
    @@ -0,0 +1,139 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.ml.classification
    +
    +import org.apache.spark.ml._
    +import org.apache.spark.ml.param._
    +import org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS
    +import org.apache.spark.mllib.linalg.{BLAS, Vector, VectorUDT}
    +import org.apache.spark.mllib.regression.LabeledPoint
    +import org.apache.spark.sql._
    +import org.apache.spark.sql.catalyst.analysis.Star
    +import org.apache.spark.sql.catalyst.dsl._
    +import org.apache.spark.storage.StorageLevel
    +
    +/**
    + * Params for logistic regression.
    + */
    +private[classification] trait LogisticRegressionParams extends Params
    +  with HasRegParam with HasMaxIter with HasLabelCol with HasThreshold with 
HasFeaturesCol
    +  with HasScoreCol with HasPredictionCol
    +
    +/**
    + * Logistic regression.
    + */
    +class LogisticRegression extends Estimator[LogisticRegressionModel] with 
LogisticRegressionParams {
    +
    +  setRegParam(0.1)
    +  setMaxIter(100)
    +  setThreshold(0.5)
    +
    +  def setRegParam(value: Double): this.type = { set(regParam, value); this 
}
    +  def setMaxIter(value: Int): this.type = { set(maxIter, value); this }
    +  def setLabelCol(value: String): this.type = { set(labelCol, value); this 
}
    +  def setThreshold(value: Double): this.type = { set(threshold, value); 
this }
    +  def setFeaturesCol(value: String): this.type = { set(featuresCol, 
value); this }
    +  def setScoreCol(value: String): this.type = { set(scoreCol, value); this 
}
    +  def setPredictionCol(value: String): this.type = { set(predictionCol, 
value); this }
    +
    +  override def fit(dataset: SchemaRDD, paramMap: ParamMap): 
LogisticRegressionModel = {
    +    transform(dataset.schema, paramMap, logging = true)
    +    import dataset.sqlContext._
    +    val map = this.paramMap ++ paramMap
    +    val instances = dataset.select(map(labelCol).attr, 
map(featuresCol).attr)
    +      .map { case Row(label: Double, features: Vector) =>
    +        LabeledPoint(label, features)
    +      }.persist(StorageLevel.MEMORY_AND_DISK)
    +    val lr = new LogisticRegressionWithLBFGS
    +    lr.optimizer
    +      .setRegParam(map(regParam))
    +      .setNumIterations(map(maxIter))
    +    val lrm = new LogisticRegressionModel(this, map, 
lr.run(instances).weights)
    +    instances.unpersist()
    +    // copy model params
    +    Params.copyValues(this, lrm)
    --- End diff --
    
    Does this mean this Estimator's params override the paramMap given to fit() 
for the model, but vice versa during fit()?


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