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

    https://github.com/apache/spark/pull/9934#discussion_r58101682
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/classification/OneVsRestSuite.scala ---
    @@ -160,6 +160,83 @@ class OneVsRestSuite extends SparkFunSuite with 
MLlibTestSparkContext {
           require(m.getThreshold === 0.1, "copy should handle extra model 
params")
         }
       }
    +
    +  test("read/write: OneVsRest") {
    +    val lr = new LogisticRegression().setMaxIter(10).setRegParam(0.01)
    +
    +    val ova = new OneVsRest()
    +      .setClassifier(lr)
    +      .setLabelCol("myLabel")
    +      .setFeaturesCol("myFeature")
    +      .setPredictionCol("myPrediction")
    +
    +    val ova2 = testDefaultReadWrite(ova, testParams = false)
    +    assert(ova.uid === ova2.uid)
    +    assert(ova.getFeaturesCol === ova2.getFeaturesCol)
    +    assert(ova.getLabelCol === ova2.getLabelCol)
    +    assert(ova.getPredictionCol === ova2.getPredictionCol)
    +
    +    ova2.getClassifier match {
    +      case lr2: LogisticRegression =>
    +        assert(lr.uid === lr2.uid)
    +        assert(lr.getMaxIter === lr2.getMaxIter)
    +        assert(lr.getRegParam === lr2.getRegParam)
    +      case other =>
    +        throw new AssertionError(s"Loaded OneVsRest expected classifier of 
type" +
    +          s" LogisticRegression but found ${other.getClass.getName}")
    +    }
    +  }
    +
    +  test("read/write: OneVsRestModel") {
    +    def checkModelData(model: OneVsRestModel, model2: OneVsRestModel): 
Unit = {
    +      assert(model.uid === model2.uid)
    +      assert(model.getFeaturesCol === model2.getFeaturesCol)
    +      assert(model.getLabelCol === model2.getLabelCol)
    +      assert(model.getPredictionCol === model2.getPredictionCol)
    +
    +    model2.getClassifier match {
    +      case lr2: LogisticRegression =>
    +        assert(model.getClassifier.asInstanceOf[LogisticRegression].uid 
=== lr2.uid)
    +        
assert(model.getClassifier.asInstanceOf[LogisticRegression].getMaxIter === 
lr2.getMaxIter)
    +        
assert(model.getClassifier.asInstanceOf[LogisticRegression].getRegParam === 
lr2.getRegParam)
    +      case other =>
    +        throw new AssertionError(s"Loaded OneVsRestModel expected 
classifier of type" +
    +          s" LogisticRegression but found ${other.getClass.getName}")
    +    }
    +      assert(model.labelMetadata === model2.labelMetadata)
    +      model.models.zip(model2.models).foreach {
    +        case (lrModel1: LogisticRegressionModel, lrModel2: 
LogisticRegressionModel) =>
    +          assert(lrModel1.uid === lrModel2.uid)
    +          assert(lrModel1.coefficients === lrModel2.coefficients)
    +          assert(lrModel1.intercept === lrModel2.intercept)
    +        case other =>
    +          throw new AssertionError(s"Loaded OneVsRestModel expected model 
of type" +
    +            s" LogisticRegressionModel but found 
${other.getClass.getName}")
    +      }
    +    }
    +
    +    val labelIndexer = new StringIndexer()
    --- End diff --
    
    Right!  I forgot LogReg does not require label metadata.


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