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

    https://github.com/apache/spark/pull/12420#discussion_r60479728
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/Pipeline.scala ---
    @@ -309,6 +321,32 @@ class PipelineModel private[ml] (
     
       @Since("1.6.0")
       override def write: MLWriter = new 
PipelineModel.PipelineModelWriter(this)
    +
    +  /** Returns stage at index i in PipelineModel */
    +  @Since("2.0.0")
    +  def getStage[T <: Transformer](i: Int): T = {
    +    stages.apply(i).asInstanceOf[T]
    +  }
    +
    +  /**
    +   * Returns stage given its parent or generating instance in 
PipelineModel.
    +   * E.g., if this PipelineModel was created from a Pipeline containing a 
stage
    +   * {{myStage}}, then passing {{myStage}} to this method will return the
    +   * corresponding stage in this PipelineModel.
    +   */
    +  @Since("2.0.0")
    +  def getStage[T <: Transformer, E <: PipelineStage](stage: E): T = {
    +    val idxInPipeline = 
this.parent.asInstanceOf[Pipeline].getStages.indexOf(stage)
    --- End diff --
    
    This should test against the uid, not the stage reference.


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