Github user feynmanliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/8507#discussion_r38373099
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala ---
@@ -202,17 +202,24 @@ object NaiveBayesModel extends
Loader[NaiveBayesModel] {
sc.parallelize(Seq(metadata), 1).saveAsTextFile(metadataPath(path))
// Create Parquet data.
- val dataRDD: DataFrame = sc.parallelize(Seq(data), 1).toDF()
- dataRDD.write.parquet(dataPath(path))
+ val dataRDD = sc.parallelize(Seq(Row(data.labels, data.pi,
data.theta, data.modelType)), 1)
+ sqlContext.createDataFrame(dataRDD,
schema).write.parquet(dataPath(path))
}
+ private val schema = StructType(
+ StructField("labels", ArrayType(DoubleType, containsNull = false),
nullable = false)::
+ StructField("pi", ArrayType(DoubleType, containsNull = false),
nullable = false)::
+ StructField("theta", ArrayType(
+ ArrayType(DoubleType, containsNull = false), containsNull =
false), nullable = false)::
+ StructField("modelType", StringType, nullable = false)::Nil)
--- End diff --
Use a `Seq()` here instead of cons-list
---
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]