Contenuto principale

remove

Remove existing components or pipelines from pipeline

Since R2026a

    Description

    newPipeline = remove(pipeline,pipeNames) removes the components and pipelines listed in pipeNames from the pipeline pipeline. All connections to the pipeNames components and pipelines are also removed. pipeNames cannot refer to a component within a subpipeline of pipeline.

    example

    Examples

    collapse all

    Create a pipeline with data preprocessing components.

    removeMissing = observationRemoverComponent;
    normalizer = normalizerComponent;
    oneHotEncoder = oneHotEncoderComponent;
    pcaTransformer = pcaComponent;
    pipeline1 = series(removeMissing, ...
        parallel(normalizer,oneHotEncoder), ...
        pcaTransformer);
    pipeline1.Components
    ans = 
    
      struct with fields:
    
        ObservationRemover: [1×1 observationRemoverComponent]
                Normalizer: [1×1 normalizerComponent]
             OneHotEncoder: [1×1 oneHotEncoderComponent]
                       PCA: [1×1 pcaComponent]

    View the pipeline.

    view(pipeline1)

    View pipeline

    Remove the normalizer and oneHotEncoder components from the pipeline. You must use the names of the components in the pipeline, not the user-specified names. Then, view the pipeline.

    pipeline2 = remove(pipeline1,["Normalizer","OneHotEncoder"]);
    pipeline2.Connections
    ans =
    
      4×2 table
    
                   Source                        Destination         
        _____________________________    ____________________________
    
        "DataIn1"                        "ObservationRemover/DataIn1"
        "DataIn2"                        "ObservationRemover/DataIn2"
        "PCA/DataOut"                    "DataOut"                   
        "ObservationRemover/DataOut2"    "DataOut2"                    

    View pipeline

    The remaining two components, removeMissing and pcaTransformer, are not connected.

    Connect the two components. The number of outputs of removeMissing is not equivalent to the number of inputs of pcaTransformer. So, you must specify the input and output ports to connect. To find the names of the inputs and outputs of the components, use the previous visualization.

    pipeline3 = connect(pipeline2,["ObservationRemover/DataOut1", ...
        "PCA/DataIn"]);
    pipeline3.Connections
    ans =
    
      5×2 table
    
                   Source                        Destination         
        _____________________________    ____________________________
    
        "DataIn1"                        "ObservationRemover/DataIn1"
        "DataIn2"                        "ObservationRemover/DataIn2"
        "ObservationRemover/DataOut1"    "PCA/DataIn"                
        "PCA/DataOut"                    "DataOut"                   
        "ObservationRemover/DataOut2"    "DataOut2"                   

    View the final pipeline.

    View pipeline

    Input Arguments

    collapse all

    Existing pipeline, specified as a LearningPipeline object.

    Names of the components and pipelines to remove from the existing pipeline, specified as a character vector, string array, or cell array of character vectors.

    Data Types: char | string | cell

    Output Arguments

    collapse all

    Pipeline without the specified components and pipelines listed in pipeNames, returned as a LearningPipeline object.

    Tips

    • To remove ports from a pipeline p, remove names from the pipeline properties p.Inputs or p.Outputs. For example, to remove the port named "X" from the pipeline's outputs, specify p.Outputs(p.Outputs=="X") = [].

    Version History

    Introduced in R2026a