Skip to content

Commit

Permalink
fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
yanboliang committed Apr 21, 2015
1 parent f80ec1b commit 872028d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ object IsotonicRegressionModel extends Loader[IsotonicRegressionModel] {
predictions: Array[Double],
isotonic: Boolean): Unit = {
val sqlContext = new SQLContext(sc)
import sqlContext.implicits._

val metadata = compact(render(
("class" -> thisClassName) ~ ("version" -> thisFormatVersion) ~
("isotonic" -> isotonic)))
sc.parallelize(Seq(metadata), 1).saveAsTextFile(metadataPath(path))

sqlContext.createDataFrame(boundaries.toSeq.zip(predictions)
.map { case (b, p) => Data(b, p) }).saveAsParquetFile(dataPath(path))
sqlContext.createDataFrame(
boundaries.toSeq.zip(predictions).map { case (b, p) => Data(b, p) }
).saveAsParquetFile(dataPath(path))
}

def load(sc: SparkContext, path: String): (Array[Double], Array[Double]) = {
Expand All @@ -177,8 +177,9 @@ object IsotonicRegressionModel extends Loader[IsotonicRegressionModel] {

checkSchema[Data](dataRDD.schema)
val dataArray = dataRDD.select("boundary", "prediction").collect()
val (boundaries, predictions) = dataArray.map {
x => (x.getDouble(0), x.getDouble(1)) }.toList.sortBy(_._1).unzip
val (boundaries, predictions) = dataArray.map { x =>
(x.getDouble(0), x.getDouble(1))
}.toList.sortBy(_._1).unzip
(boundaries.toArray, predictions.toArray)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class IsotonicRegressionSuite extends FunSuite with MLlibTestSparkContext with M
val sameModel = IsotonicRegressionModel.load(sc, path)
assert(model.boundaries === sameModel.boundaries)
assert(model.predictions === sameModel.predictions)
assert(model.isotonic == model.isotonic)
assert(model.isotonic === model.isotonic)
} finally {
Utils.deleteRecursively(tempDir)
}
Expand Down

0 comments on commit 872028d

Please sign in to comment.