Contenuto principale

add

Add new component or pipeline to existing pipeline

Since R2026a

    Description

    newPipeline = add(pipeline,pipe) adds the component or pipeline pipe to the pipeline pipeline, and returns the added element in the pipeline newPipeline. If pipe has the same name as an existing component or pipeline in pipeline, the function adds a numeric suffix to the name of pipe to make it unique.

    example

    newPipeline = add(pipeline,pipe1,...,pipeN) adds the components or pipelines pipe1 through pipeN to pipeline, and returns the added elements in newPipeline.

    [newPipeline,newNames] = add(___) also returns newNames, which contains the names of all added elements in the same order as the components and pipelines passed to add, using any of the input argument combinations in the previous syntaxes.

    Examples

    collapse all

    Create a pipeline object with two components.

    removeMissing = observationRemoverComponent;
    ecoc = classificationECOCComponent;
    pipeline = series(removeMissing,ecoc)
    
    pipeline = 
    
      LearningPipeline with properties:
    
                 Name: "defaultName"
               Inputs: ["DataIn1"    "DataIn2"]
            InputTags: [1 2]
              Outputs: ["Predictions"    "Scores"    "Loss"    "DataOut2"]
           OutputTags: [1 0 0 2]
    
           Components: struct with 2 entries
          Connections: [8×2 table]
    
        HasLearnables: true
           HasLearned: false
    
    
    Show summary of the components

    pipeline is a LearningPipeline object with default properties.

    Create a component to normalize predictor values and add it to the pipeline. Display the pipeline connections, and then view the pipeline.

    normalize = normalizerComponent;
    pipeline2 = add(pipeline,normalize);
    pipeline2.Connections
    view(pipeline2)
    ans =
    
      8×2 table
    
                     Source                           Destination          
        ________________________________    _______________________________
    
        "DataIn1"                           "ObservationRemover/DataIn1"   
        "DataIn2"                           "ObservationRemover/DataIn2"   
        "ObservationRemover/DataOut1"       "ClassificationECOC/Predictors"
        "ObservationRemover/DataOut2"       "ClassificationECOC/Response"  
        "ClassificationECOC/Predictions"    "Predictions"                  
        "ObservationRemover/DataOut2"       "DataOut2"                     
        "ClassificationECOC/Scores"         "Scores"                       
        "ClassificationECOC/Loss"           "Loss"                         
    

    View pipeline

    The add function does not automatically connect components.

    Manually connect Normalizer to the rest of the pipeline. Connect the input of Normalizer to the DataOut1 output of the ObservationRemover component, and connect the DataScaled output of Normalizer to the Predictors input of the ClassificationECOC component. Also, disconnect the DataOut1 output of ObservationRemover from the Predictors input of the ClassificationECOC component.

    pipeline3 = connect(pipeline2,["ObservationRemover/DataOut1", ...
        "Normalizer/DataIn","Normalizer/DataScaled", ...
        "ClassificationECOC/Predictors"]);
    pipeline3 = disconnect(pipeline3,["ObservationRemover/DataOut1", ...
        "ClassificationECOC/Predictors"]);

    View the updated pipeline.

    View pipeline

    Input Arguments

    collapse all

    Existing pipeline, specified as a LearningPipeline object.

    Element to add to the existing pipeline, specified as a LearningPipeline or learning component object. For a list of learning component objects, see pipe.

    Output Arguments

    collapse all

    Pipeline containing the added elements, returned as a LearningPipeline object.

    Names of all the elements added to the pipeline pipeline to form newPipeline, returned as a string array. If add renames any element, newNames contains the new name.

    Tips

    • To add ports to a pipeline p, add names to the pipeline properties p.Inputs or p.Outputs.

    Version History

    Introduced in R2026a