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

    https://github.com/apache/spark/pull/12066#discussion_r61474754
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/classification/NaiveBayesSuite.scala 
---
    @@ -193,6 +195,30 @@ class NaiveBayesSuite extends SparkFunSuite with 
MLlibTestSparkContext with Defa
             assert(expected.theta === actual.theta)
           }
       }
    +
    +  test("copy label column metadata to prediction column") {
    +    val data = sc.parallelize(Seq((Vectors.dense(0.0), "a"), 
(Vectors.dense(1.0), "b"),
    +      (Vectors.dense(2.0), "c"), (Vectors.dense(3.0), "a"), 
(Vectors.dense(4.0), "a")), 2)
    +    var df = sqlContext.createDataFrame(data).toDF("features", "label")
    +
    +    val indexer = new StringIndexer()
    +      .setInputCol("label")
    +      .setOutputCol("labelIndex")
    +      .fit(df)
    +    df = indexer.transform(df)
    +
    +    val naiveBayes = new NaiveBayes().setLabelCol("labelIndex")
    +    val naiveBayesModel = naiveBayes.fit(df)
    +    df = naiveBayesModel.transform(df)
    +
    +    val schema = df.schema
    +    val labelAttr = 
Attribute.fromStructField(schema(naiveBayesModel.getLabelCol))
    +      .asInstanceOf[NominalAttribute]
    +    val predictionAttr = 
Attribute.fromStructField(schema(naiveBayesModel.getPredictionCol))
    +      .asInstanceOf[NominalAttribute]
    +    assert(labelAttr.attrType === predictionAttr.attrType)
    --- End diff --
    
    Check that the "name" field matches predictionCol too


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