Spark: мне нужно сохранить прогноз из-под кода Scala в файл, а не показывать его ?? как мне это сделать??
val sameModel = PipelineModel.load ("/ tmp / spark-logistic-regression-model")
< val rawDataTest = sc.textFile("/home/hduser1/Pictures/LogTextTest.txt")
val header1 = rawDataTest.first()
val rawDataTest1 = rawDataTest.filter(line => line != header1)
val records1 = rawDataTest1.map(line => line.split(","))
records1.first()
case class StumbleUpon1(id: String, text: String)
val data1 = records1.map{ r1 =>
val trimmed1 = r1.map(_.replaceAll("\"", ""))
//val label1 = trimmed(r1.size - 1).toInt
val features = trimmed1.slice(0, r1.size)
assert(features.size == 2)
StumbleUpon1(features(0), features(1))
}
data1.first()
val Test = data1.toDF("id", "text")
Test.show(15)
val predictions = model.transform(Test)
predictions.show(5) >