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

    https://github.com/apache/spark/pull/9836#discussion_r45384012
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/regression/IsotonicRegression.scala ---
    @@ -240,4 +254,61 @@ class IsotonicRegressionModel private[ml] (
       override def transformSchema(schema: StructType): StructType = {
         validateAndTransformSchema(schema, fitting = false)
       }
    +
    +  @Since("1.6.0")
    +  override def write: MLWriter =
    +    new IsotonicRegressionModelWriter(this)
    +}
    +
    +@Since("1.6.0")
    +object IsotonicRegressionModel extends MLReadable[IsotonicRegressionModel] 
{
    +
    +  @Since("1.6.0")
    +  override def read: MLReader[IsotonicRegressionModel] = new 
IsotonicRegressionModelReader
    +
    +  @Since("1.6.0")
    +  override def load(path: String): IsotonicRegressionModel = 
super.load(path)
    +
    +  /** [[MLWriter]] instance for [[IsotonicRegressionModel]] */
    +  private[IsotonicRegressionModel] class IsotonicRegressionModelWriter (
    +      instance: IsotonicRegressionModel
    +    ) extends MLWriter with Logging {
    +
    +    private case class Data(
    +        boundaries: Array[Double],
    +        predictions: Array[Double],
    +        isotonic: Boolean)
    +
    +    override protected def saveImpl(path: String): Unit = {
    +      // Save metadata and Params
    +      DefaultParamsWriter.saveMetadata(instance, path, sc)
    +      // Save model data: boundaries, predictions, isotonic
    +      val data = Data(
    +        instance.oldModel.boundaries, instance.oldModel.predictions, 
instance.oldModel.isotonic)
    +      val dataPath = new Path(path, "data").toString
    +      
sqlContext.createDataFrame(Seq(data)).repartition(1).write.parquet(dataPath)
    +    }
    +  }
    +
    +  private class IsotonicRegressionModelReader extends 
MLReader[IsotonicRegressionModel] {
    +
    +    /** Checked against metadata when loading model */
    +    private val className = classOf[IsotonicRegressionModel].getName
    +
    +    override def load(path: String): IsotonicRegressionModel = {
    +      val metadata = DefaultParamsReader.loadMetadata(path, sc, className)
    +
    +      val dataPath = new Path(path, "data").toString
    +      val data = sqlContext.read.format("parquet").load(dataPath)
    --- End diff --
    
    minor: `sqlContext.read.parquet(dataPath)`


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