Github user mengxr commented on a diff in the pull request: https://github.com/apache/spark/pull/5270#discussion_r27781276 --- Diff: mllib/src/main/scala/org/apache/spark/mllib/regression/IsotonicRegression.scala --- @@ -124,6 +131,74 @@ class IsotonicRegressionModel ( predictions(foundIndex) } } + + override def save(sc: SparkContext, path: String): Unit = { + val intervals = boundaries.toList.zip(predictions.toList).toArray + val data = IsotonicRegressionModel.SaveLoadV1_0.Data(intervals) + IsotonicRegressionModel.SaveLoadV1_0.save(sc, path, data, isotonic) + } + + override protected def formatVersion: String = "1.0" +} + +object IsotonicRegressionModel extends Loader[IsotonicRegressionModel] { + + import org.apache.spark.mllib.util.Loader._ + + private object SaveLoadV1_0 { + + def thisFormatVersion: String = "1.0" + + /** Hard-code class name string in case it changes in the future */ + def thisClassName: String = "org.apache.spark.mllib.regression.IsotonicRegressionModel" + + /** Model data for model import/export */ + case class Data(intervals: Array[(Double, Double)]) --- End diff -- My suggestion was ~~~scala case class Data(boundary: Double, prediction: Double) ~~~ And then save each `(boundary, prediction)` pair as a record: ~~~scala sqlContext.createDataFrame(boundaries.zip(predictions).map { case (b, p) => Data(b, p) }) .saveAsParquetFile(dataPath(path)) ~~~
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org