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

    https://github.com/apache/spark/pull/13301#discussion_r64652199
  
    --- Diff: 
examples/src/main/scala/org/apache/spark/examples/mllib/NaiveBayesExample.scala 
---
    @@ -31,21 +32,17 @@ object NaiveBayesExample {
         val conf = new SparkConf().setAppName("NaiveBayesExample")
         val sc = new SparkContext(conf)
         // $example on$
    -    val data = sc.textFile("data/mllib/sample_naive_bayes_data.txt")
    -    val parsedData = data.map { line =>
    -      val parts = line.split(',')
    -      LabeledPoint(parts(0).toDouble, Vectors.dense(parts(1).split(' 
').map(_.toDouble)))
    -    }
    +    // Load and parse the data file.
    +    val data = MLUtils.loadLibSVMFile(sc, 
"data/mllib/sample_libsvm_data.txt")
     
         // Split data into training (60%) and test (40%).
    -    val splits = parsedData.randomSplit(Array(0.6, 0.4), seed = 11L)
    -    val training = splits(0)
    -    val test = splits(1)
    +    val splits = data.randomSplit(Array(0.6, 0.4))
    +    val (trainingData, testData) = (splits(0), splits(1))
    --- End diff --
    
    Lets not change the variable names, since they were consistent.
    But hey in Scala this can be `val Array(training, test) = 
data.randomSplit(...)`


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

Reply via email to