Contenuto principale

featureSelectionClassificationANOVAComponent

Pipeline component for performing feature selection using ANOVA algorithm

Since R2026a

    Description

    featureSelectionClassificationANOVAComponent is a pipeline component that performs feature selection using one-way analysis of variance (ANOVA). The pipeline component uses the functionality of the anova1 function during the learn phase to identify important predictors in the data. During the run phase, the component selects the same predictors from a new data set.

    Creation

    Description

    component = featureSelectionClassificationANOVAComponent creates a pipeline component for feature selection using ANOVA. Use the component when creating a pipeline for classification.

    component = featureSelectionClassificationANOVAComponent(Name=Value) sets writable Properties using one or more name-value arguments. For example, NumFeatures=10 specifies to select 10 important features.

    example

    Properties

    expand all

    Learn Parameters

    The software sets learn parameters when you create the component. You can modify learn parameters using dot notation any time before you use the learn object function. Any unset learn parameters use the corresponding default values.

    Number of features (predictors) to select, specified as a positive integer scalar.

    If you do not specify the NumFeatures or RelativeScoreThreshold value, the software selects all features. You cannot specify both NumFeatures and RelativeScoreThresold.

    Example: c = featureSelectionClassificationANOVAComponent(NumFeatures=5)

    Example: c.NumFeatures = 10

    Data Types: single | double

    Relative score threshold for selecting features, specified as a numeric scalar in the range (0,1].

    • When the maximum feature (predictor) score is a finite value smax, the software selects a feature with score s if s/smax is greater than or equal to the RelativeScoreThreshold value.

    • When the maximum feature score is infinite, the software selects each feature with an Inf score.

    If you do not specify the NumFeatures or RelativeScoreThresold value, the software selects all features. You cannot specify both NumFeatures and RelativeScoreThresold.

    Example: c = featureSelectionClassificationANOVAComponent(RelativeScoreThreshold=0.5)

    Example: c.RelativeScoreThreshold = 0.75

    Data Types: single | double

    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 = featureSelectionClassificationANOVAComponent(Name="FeatureSelector")

    Example: c.Name = "ANOVASelector"

    Data Types: char | string

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

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

    Example: c.Inputs = ["X1","Y1"]

    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 = featureSelectionClassificationANOVAComponent(Outputs=["newX","importance"])

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

    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, then the number of tags must match the number of inputs in Inputs.

    Example: c = featureSelectionClassificationANOVAComponent(InputTags=[1 0])

    Example: c.InputTags = [1 2]

    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, then the number of tags must match the number of outputs in Outputs.

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

    Example: c.OutputTags=[1 2]

    Data Types: single | double

    This property is read-only.

    Indicator for the learnables, returned as 1 (true). A value of 1 indicates that the component contains 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 and the Learnables are nonempty.

    Data Types: logical

    Learnables

    The software sets learnables when you use the learn object function. You cannot modify learnables directly.

    This property is read-only.

    Names of the features selected by the component, returned as a string array. The features correspond to columns in the first data argument of learn.

    Data Types: string

    This property is read-only.

    Names of the variables used by the component to select features, returned as a string array. The variables correspond to columns in the first data argument of learn.

    Data Types: string

    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 featureSelectionClassificationANOVAComponent pipeline component. Specify to select 3 features

    component = featureSelectionClassificationANOVAComponent(NumFeatures=3)
    component = 
      featureSelectionClassificationANOVAComponent with properties:
    
                     Name: "FeatureSelectionClassificationANOVA"
                   Inputs: ["X"    "Y"]
                InputTags: [1 2]
                  Outputs: ["XSelected"    "Scores"]
               OutputTags: [1 NaN]
    
       
    Learnables (HasLearned = false)
        SelectedVariables: []
            UsedVariables: []
    
       
    Learn Parameters (unlocked)
              NumFeatures: 3
    
    
    Show all parameters
    

    component is a featureSelectionClassificationANOVAComponent object that contains two learnables: SelectedVariables and UsedVariables. These properties remains empty until you pass data to the component during the learn phase.

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

    fisheriris = readtable("fisheriris.csv");
    X = fisheriris(:,1:end-1);
    Y = fisheriris(:,end);

    Use the learn object function to select features from the predictor data X.

    component = learn(component,X,Y)
    component = 
      featureSelectionClassificationANOVAComponent with properties:
    
                     Name: "FeatureSelectionClassificationANOVA"
                   Inputs: ["X"    "Y"]
                InputTags: [1 2]
                  Outputs: ["XSelected"    "Scores"]
               OutputTags: [1 NaN]
    
       
    Learnables (HasLearned = true)
        SelectedVariables: ["PetalLength"    "PetalWidth"    "SepalLength"]
            UsedVariables: ["SepalLength"    "SepalWidth"    "PetalLength"    "PetalWidth"]
    
       
    Learn Parameters (locked)
              NumFeatures: 3
    
    
    Show all parameters
    

    Note that the HasLearned property is set to true and the SelectedVariables and UsedVariables are nonempty.

    Find the names of the selected features.

    names = component.SelectedVariables
    names = 
    
      1×3 string array
    
        "PetalLength"    "PetalWidth"    "SepalLength"
    

    Version History

    Introduced in R2026a

    See Also