Main Content

expand

Expand subpipelines in pipeline

Since R2026a

    Description

    expandedPipeline = expand(pipeline) expands all subpipelines in pipeline, excluding nested subpipelines (for example, subpipelines of subpipelines). The function reconnects the ports of the subpipeline components to the corresponding ports in pipeline.

    Because components within a pipeline must have unique names, expand resolves any naming conflicts by appending a numeric suffix to the component names from the subpipelines.

    example

    expandedPipeline = expand(pipeline,subpipelineNames) expands the subpipelines specified by subpipelineNames.

    Examples

    collapse all

    Build a pipeline with a collapsed subpipeline. Then expand the subpipeline.

    Create a data preprocessing pipeline with two components: one that removes observations with missing values, and one that retains the principal components that explain 95% of the variance.

    preprocessPipeline = series(observationRemoverComponent, ...
        pcaComponent(VarianceExplained=0.95));
    preprocessPipeline.Name = "PreprocessPipeline";

    Create a classification pipeline using the data preprocessing pipeline and a classification tree component. In the call to series, set ExpandSubpipelines to false to collapse the data preprocessing pipeline in the classification pipeline. Inspect the Components property of the classification pipeline to see its entries.

    classificationPipeline = series(preprocessPipeline, ...
        classificationTreeComponent, ...
        ExpandSubpipelines=false);
    classificationPipeline.Name="ClassificationPipeline";
    classificationPipeline.Components
    ans = 
    
      struct with fields:
    
        PreprocessPipeline: [1×1 LearningPipeline]
        ClassificationTree: [1×1 classificationTreeComponent]

    The classification pipeline contains two entries, including the subpipeline PreprocessPipeline.

    Next, expand the subpipeline in the classification pipeline and inspect the Components property of the classification pipeline to see its entries.

    expandedClassificationPipeline = expand(classificationPipeline);
    expandedClassificationPipeline.Components
    ans = 
    
      struct with fields:
    
        ObservationRemover: [1×1 observationRemoverComponent]
                       PCA: [1×1 pcaComponent]
        ClassificationTree: [1×1 classificationTreeComponent]

    The expanded classification pipeline contains three entries, including the two components in the data preprocessing pipeline.

    Input Arguments

    collapse all

    Existing pipeline, specified as a LearningPipeline object.

    Names of the subpipelines in pipeline to expand, specified as a character vector, string array, or cell array of character vectors.

    Data Types: char | string | cell

    Output Arguments

    collapse all

    Pipeline with expanded subpipelines, returned as a LearningPipeline object. You can see the expanded subpipelines in the Components property of expandedPipeline.

    Tips

    • If you want to create a pipeline with many components, consider creating subpipelines and combining them using series or parallel with ExpandSubpipelines set to false. The view function then provides a more streamlined visualization of the complete pipeline.

    Version History

    Introduced in R2026a