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

    https://github.com/apache/spark/pull/9798#discussion_r45245113
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/feature/StandardScaler.scala ---
    @@ -138,4 +163,49 @@ class StandardScalerModel private[ml] (
         val copied = new StandardScalerModel(uid, scaler)
         copyValues(copied, extra).setParent(parent)
       }
    +
    +  @Since("1.6.0")
    +  override def write: Writer = new StandardScalerModelWriter(this)
    +}
    +
    +@Since("1.6.0")
    +object StandardScalerModel extends Readable[StandardScalerModel] {
    +
    +  private[StandardScalerModel]
    +  class StandardScalerModelWriter(instance: StandardScalerModel) extends 
Writer {
    +
    +    private case class Data(std: Vector, mean: Vector, withStd: Boolean, 
withMean: Boolean)
    +
    +    override protected def saveImpl(path: String): Unit = {
    +      DefaultParamsWriter.saveMetadata(instance, path, sc)
    +      val data = Data(instance.std, instance.mean, instance.getWithStd, 
instance.getWithMean)
    +      val dataPath = new Path(path, "data").toString
    +      
sqlContext.createDataFrame(Seq(data)).repartition(1).write.parquet(dataPath)
    +    }
    +  }
    +
    +  private class StandardScalerModelReader extends 
Reader[StandardScalerModel] {
    +
    +    private val className = 
"org.apache.spark.ml.feature.StandardScalerModel"
    +
    +    override def load(path: String): StandardScalerModel = {
    +      val metadata = DefaultParamsReader.loadMetadata(path, sc, className)
    +      val dataPath = new Path(path, "data").toString
    +      val Row(std: Vector, mean: Vector, withStd: Boolean, withMean: 
Boolean) =
    +        sqlContext.read.parquet(dataPath)
    +          .select("std", "mean", "withStd", "withMean")
    +          .head()
    +      // This is very likely to change in the future because withStd and 
withMean should be params.
    --- End diff --
    
    They are already Params.  This is just weird b/c the new and old model 
params can get out of synch.  Fine for now though.


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