zhengruifeng edited a comment on pull request #30013:
URL: https://github.com/apache/spark/pull/30013#issuecomment-706965136


   test in commit 27eab00:
   
   ```
   import scala.util.Random
   import org.apache.spark.ml.linalg._
   import org.apache.spark.ml.classification._
   import org.apache.spark.ml.regression._
   import org.apache.spark.sql.functions._
   import org.apache.spark.storage.StorageLevel
   
   
   
   val df = spark.read.option("numFeatures", 
"2000").format("libsvm").load("/data1/Datasets/epsilon/epsilon_normalized.t").withColumn("aftcensor",
 (col("label")+1)/2).withColumn("aftlabel", 
(col("label")+2)/2).withColumn("label", (col("label")+1)/2).limit(100)
   df.persist(StorageLevel.MEMORY_AND_DISK)
   df.count
   
   val vec = df.select("features").head.getAs[Vector](0)
   
   val lor = new LogisticRegression().setMaxIter(1).setThreshold(0.1)
   
   val lorm = lor.fit(df)
   
   lorm.getThreshold
   
   lorm.predict(vec)
   
   ```
   
   results:
   // master
   scala> val lorm = lor.fit(df)
   20/10/12 15:47:23 WARN LogisticRegressionModel: **_threshold=0.5, 
_rawThreshold=0.0**
   lorm: org.apache.spark.ml.classification.LogisticRegressionModel = 
LogisticRegressionModel: uid=logreg_4c79066a563d, numClasses=2, numFeatures=2000
   
   scala> **lorm.getThreshold**
   res9: Double = **0.1**
   
   scala> lorm.predict(vec)
   20/10/12 15:47:29 WARN LogisticRegressionModel: **_threshold=0.5, 
_rawThreshold=0.0**
   res10: Double = 0.0
   
   The `_threshold` and `_rawThreshold` here are incorrect.
   
   
   // this PR
   scala> lorm.predict(vec)
   20/10/12 16:01:09 WARN LogisticRegressionModel: _threshold=0.1, 
_rawThreshold=-2.197224577336219
   res3: Double = 0.0
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to