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

    https://github.com/apache/spark/pull/15435#discussion_r94640294
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala
 ---
    @@ -1756,55 +1765,105 @@ class LogisticRegressionSuite
       }
     
       test("evaluate on test set") {
    -    // TODO: add for multiclass when model summary becomes available
         // Evaluate on test set should be same as that of the transformed 
training data.
    -    val lr = new LogisticRegression()
    +    val blor = new LogisticRegression()
           .setMaxIter(10)
           .setRegParam(1.0)
           .setThreshold(0.6)
    -    val model = lr.fit(smallBinaryDataset)
    -    val summary = 
model.summary.asInstanceOf[BinaryLogisticRegressionSummary]
    -
    -    val sameSummary =
    -      
model.evaluate(smallBinaryDataset).asInstanceOf[BinaryLogisticRegressionSummary]
    -    assert(summary.areaUnderROC === sameSummary.areaUnderROC)
    -    assert(summary.roc.collect() === sameSummary.roc.collect())
    -    assert(summary.pr.collect === sameSummary.pr.collect())
    +    val blorModel = blor.fit(smallBinaryDataset)
    +    val blorSummary = blorModel.binarySummary
    +
    +    val blorSameSummary =
    +      
blorModel.evaluate(smallBinaryDataset).asInstanceOf[BinaryLogisticRegressionSummary]
    +    assert(blorSummary.areaUnderROC === blorSameSummary.areaUnderROC)
    +    assert(blorSummary.roc.collect() === blorSameSummary.roc.collect())
    +    assert(blorSummary.pr.collect === blorSameSummary.pr.collect())
         assert(
    -      summary.fMeasureByThreshold.collect() === 
sameSummary.fMeasureByThreshold.collect())
    -    assert(summary.recallByThreshold.collect() === 
sameSummary.recallByThreshold.collect())
    +      blorSummary.fMeasureByThreshold.collect() === 
blorSameSummary.fMeasureByThreshold.collect())
    +    assert(blorSummary.recallByThreshold.collect()
    +      === blorSameSummary.recallByThreshold.collect())
         assert(
    -      summary.precisionByThreshold.collect() === 
sameSummary.precisionByThreshold.collect())
    +      blorSummary.precisionByThreshold.collect()
    +        === blorSameSummary.precisionByThreshold.collect())
    +
    +    val mlor = new LogisticRegression()
    +      .setMaxIter(10)
    +      .setRegParam(1.0)
    +      .setFamily("multinomial")
    +    val mlorModel = mlor.fit(smallMultinomialDataset)
    +    val mlorSummary = mlorModel.multinomialSummary
    +
    +    val mlorSameSummary = mlorModel.evaluate(smallMultinomialDataset)
    +        .asInstanceOf[MultinomialLogisticRegressionSummary]
    +
    +    assert(mlorSummary.labels === mlorSameSummary.labels)
    +    assert(mlorSummary.falsePositiveRateByLabel === 
mlorSameSummary.falsePositiveRateByLabel)
    +    assert(mlorSummary.precisionByLabel === 
mlorSameSummary.precisionByLabel)
    +    assert(mlorSummary.recallByLabel === mlorSameSummary.recallByLabel)
    +    assert(mlorSummary.fMeasureByLabel === mlorSameSummary.fMeasureByLabel)
    +    assert(mlorSummary.accuracy === mlorSameSummary.accuracy)
    +    assert(mlorSummary.weightedFalsePositiveRate === 
mlorSameSummary.weightedFalsePositiveRate)
    +    assert(mlorSummary.weightedPrecision === 
mlorSameSummary.weightedPrecision)
    +    assert(mlorSummary.weightedRecall === mlorSameSummary.weightedRecall)
    +    assert(mlorSummary.weightedFMeasure === 
mlorSameSummary.weightedFMeasure)
       }
     
       test("evaluate with labels that are not doubles") {
         // Evaluate a test set with Label that is a numeric type other than 
Double
    -    val lr = new LogisticRegression()
    +    val blor = new LogisticRegression()
           .setMaxIter(1)
           .setRegParam(1.0)
    -    val model = lr.fit(smallBinaryDataset)
    -    val summary = 
model.evaluate(smallBinaryDataset).asInstanceOf[BinaryLogisticRegressionSummary]
    +    val blorModel = blor.fit(smallBinaryDataset)
    +    val blorSummary = blorModel.evaluate(smallBinaryDataset)
    +      .asInstanceOf[BinaryLogisticRegressionSummary]
     
    -    val longLabelData = 
smallBinaryDataset.select(col(model.getLabelCol).cast(LongType),
    -      col(model.getFeaturesCol))
    -    val longSummary = 
model.evaluate(longLabelData).asInstanceOf[BinaryLogisticRegressionSummary]
    +    val blorLongLabelData = 
smallBinaryDataset.select(col(blorModel.getLabelCol).cast(LongType),
    --- End diff --
    
    Well, from a completeness standpoint I agree that it's better to test all 
the types that it's intended to work for. However, since it's just calling 
`cast` under the hood, it does seem a bit redundant. I'm ok leaving it as is, 
but I don't feel strongly about it.


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

Reply via email to