Contenuto principale

observationRemoverComponent

Pipeline component for removing observations

Since R2026a

    Description

    observationRemoverComponent is a pipeline component that removes observations in the data. During the learn and run phases, the pipeline component can remove observations based on a removal function. By default, the component does not remove observations during the run phase. For more information, see RunRemoval.

    Creation

    Description

    component = observationRemoverComponent creates a pipeline component for removing observations.

    component = observationRemoverComponent(Name=Value) sets writable Properties using one or more name-value arguments. For example, you can specify the removal criteria function using the FunctionHandle name-value argument.

    example

    Properties

    expand all

    Structural Parameters

    The software sets structural parameters when you create the component. You cannot modify structural parameters after the component is created.

    This property is read-only after the component is created.

    Function handle to specify removal criteria, specified as a function handle. The component applies FunctionHandle to the data argument specified by ReferenceInput and removes any observations that produce a nonzero value.

    FunctionHandle must follow the signature Y = myfun(X), where X is a table and Y is a table or array with the same number of rows as X.

    Example: c = observationRemoverComponent(FunctionHandle=@myfun)

    Example: c.FunctionHandle = @ismissing

    Data Types: function_handle

    This property is read-only after the component is created.

    Number of data flow tags to include in the component, specified as a positive integer scalar. NumDataFlow determines the number of elements in InputTags and OutputTags.

    Example: c = observationRemoverComponent(NumDataFlow=1)

    Data Types: single | double

    This property is read-only after the component is created.

    Index of the data argument passed to learn or run that is used to detect observations to remove, specified as a positive integer scalar. The component identifies observations for removal by applying FunctionHandle to the ReferenceInput data argument of learn or run.

    While the component uses only the data specified by ReferenceInput to identify observations to remove, the identified observations are removed from all the data arguments passed to learn or run.

    Example: c = observationRemoverComponent(ReferenceInput=2)

    Data Types: single | double

    Run Parameters

    The software sets run parameters when you create the component. You can modify the run parameters at any time. Any unset run parameters use the corresponding default values.

    Flag for removing observations during the run phase, specified as 0 (false) or 1 (true). If RunRemoval is true, the software removes observations from the data arguments passed to run. If RunRemoval is false, the software does not remove any observations from the data arguments passed to run and outputs the unchanged data.

    Example: c = observationRemoverComponent(RunRemoval=true)

    Example: c.RunRemoval = false

    Data Types: logical

    Component Properties

    The software sets component properties when you create the component. You can modify the component properties (excluding HasLearnables and HasLearned) using dot notation at any time. You cannot modify the HasLearnables and HasLearned properties directly.

    Component identifier, specified as a character vector or string scalar.

    Example: c = observationRemoverComponent(Name="RemoveObservations")

    Example: c.Name = "RemoveMissing"

    Data Types: char | string

    Names of the input ports, specified as a character vector, string array, or cell array of character vectors.

    Example: c = observationRemoverComponent(Inputs=["Data1","Data2"])

    Example: c.Inputs = ["X","Y"]

    Data Types: char | string | cell

    Names of the output ports, specified as a character vector, string array, or cell array of character vectors.

    Example: c = observationRemoverComponent(Outputs=["Data1","Data2"])

    Example: c.Outputs = ["X","Y"]

    Data Types: char | string | cell

    Tags that enable the automatic connection of the component inputs with other components or pipelines, specified as a nonnegative integer vector. If you specify InputTags, the number of tags must match the number of inputs in Inputs.

    Example: c = observationRemoverComponent(InputTags=[1 2])

    Example: c.InputTags = [2 1]

    Data Types: single | double

    Tags that enable the automatic connection of the component outputs with other components or pipelines, specified as a nonnegative integer vector. If you specify OutputTags, the number of tags must match the number of outputs in Outputs.

    Example: c = observationRemoverComponent(OutputTags=[1 0])

    Example: c.OutputTags=[1 2]

    Data Types: single | double

    This property is read-only.

    Indicator for the learnables, returned as 0 (false). A value of 0 indicates that the component does not contain learnables.

    Data Types: logical

    This property is read-only.

    Indicator showing the learning status of the component, returned as 0 (false) or 1 (true). A value of 1 indicates that the learn object function has been applied to the component..

    Data Types: logical

    Object Functions

    learnInitialize and evaluate pipeline or component
    runExecute pipeline or component for inference after learning
    resetReset pipeline or component
    seriesConnect components in series to create pipeline
    parallelConnect components or pipelines in parallel to create pipeline
    viewView diagram of pipeline inputs, outputs, components, and connections

    Examples

    collapse all

    Create a, observationRemoverComponent pipeline component. Specify to remove observations based on the second data argument. The component will remove any observations that have a missing value in the response variable.

    component = observationRemoverComponent(ReferenceInput=2)
    component = 
      observationRemoverComponent with properties:
    
                  Name: "ObservationRemover"
                Inputs: ["DataIn1"    "DataIn2"]
             InputTags: [1 2]
               Outputs: ["DataOut1"    "DataOut2"]
            OutputTags: [1 2]
    
       
    Learnables (HasLearned = false)
        No properties.
    
       
    Structural Parameters (locked)
           NumDataFlow: 2
        ReferenceInput: 2
        FunctionHandle: @ismissing
    
       
    Run Parameters (unlocked)
            RunRemoval: 0
    
    
    Show all parameters

    Read the carsmall data set into a table. Store the predictor and response data in the tables X and Y, respectively.

    load carsmall
    X = table(Cylinders,Displacement,Horsepower,Weight);
    Y = table(MPG);

    Use the learn object function to learn the component and remove observations with missing response values from the data.

    [component,newX,newY] = learn(component,X,Y);
    component
    component = 
      observationRemoverComponent with properties:
    
                  Name: "ObservationRemover"
                Inputs: ["DataIn1"    "DataIn2"]
             InputTags: [1 2]
               Outputs: ["DataOut1"    "DataOut2"]
            OutputTags: [1 2]
    
       
    Learnables (HasLearned = true)
        No properties.
    
       
    Structural Parameters (locked)
           NumDataFlow: 2
        ReferenceInput: 2
        FunctionHandle: @ismissing
    
       
    Run Parameters (unlocked)
            RunRemoval: 0
    
    
    Show all parameters

    Note that the HasLearned property is set to true, indicating that the component has learned.

    Compute the number of missing observations removed by the component.

    missing = height(X)-height(newX)
    missing = 6

    Version History

    Introduced in R2026a