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

    https://github.com/apache/spark/pull/18281#discussion_r123676033
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/classification/OneVsRest.scala ---
    @@ -325,20 +359,28 @@ final class OneVsRest @Since("1.4.0") (
           multiclassLabeled.persist(StorageLevel.MEMORY_AND_DISK)
         }
     
    +    val executor = getExecutorService
    +    val executionContext = ExecutionContext.fromExecutorService(executor)
    +
         // create k columns, one for each binary classifier.
    -    val models = Range(0, numClasses).par.map { index =>
    -      // generate new label metadata for the binary problem.
    -      val newLabelMeta = 
BinaryAttribute.defaultAttr.withName("label").toMetadata()
    -      val labelColName = "mc2b$" + index
    -      val trainingDataset = multiclassLabeled.withColumn(
    -        labelColName, when(col($(labelCol)) === index.toDouble, 
1.0).otherwise(0.0), newLabelMeta)
    -      val classifier = getClassifier
    -      val paramMap = new ParamMap()
    -      paramMap.put(classifier.labelCol -> labelColName)
    -      paramMap.put(classifier.featuresCol -> getFeaturesCol)
    -      paramMap.put(classifier.predictionCol -> getPredictionCol)
    -      classifier.fit(trainingDataset, paramMap)
    -    }.toArray[ClassificationModel[_, _]]
    +    val modelFutures = Range(0, numClasses).map { index =>
    +      Future[ClassificationModel[_, _]] {
    +        // generate new label metadata for the binary problem.
    +        val newLabelMeta = 
BinaryAttribute.defaultAttr.withName("label").toMetadata()
    +        val labelColName = "mc2b$" + index
    +        val trainingDataset = multiclassLabeled.withColumn(
    +          labelColName, when(col($(labelCol)) === index.toDouble, 
1.0).otherwise(0.0), newLabelMeta)
    +        val classifier = getClassifier
    +        val paramMap = new ParamMap()
    +        paramMap.put(classifier.labelCol -> labelColName)
    +        paramMap.put(classifier.featuresCol -> getFeaturesCol)
    +        paramMap.put(classifier.predictionCol -> getPredictionCol)
    +        classifier.fit(trainingDataset, paramMap)
    --- End diff --
    
    Only this line calling `fit` needs to be wrapped in the future


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