Main Content

featureSelectionClassificationReliefFComponent

Pipeline component for performing feature selection using ReliefF algorithm

Since R2026a

    Description

    featureSelectionClassificationReliefFComponent is a pipeline component that performs feature selection using the ReliefF algorithm. The pipeline component uses the functionality of the relieff 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 = featureSelectionClassificationReliefFComponent(numNeighbors) creates a pipeline component for feature selection using the ReliefF algorithm with numNeighbors nearest neighbors. Use the component when creating a pipeline for classification.

    component = featureSelectionClassificationReliefFComponent(numNeighbors,Name=Value) sets writable Properties using one or more name-value arguments. For example, you can specify the method for computing weights, distance scaling factor, and prior probabilities for each class.

    example

    Input Arguments

    expand all

    Number of nearest neighbors, specified as a positive integer scalar.

    Data Types: single | double

    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.

    Categorical predictors flag, specified as "on" or "off". If you specify "on", the component treats all predictors as categorical. Otherwise, it treats all predictors as numeric.

    Example: c = featureSelectionClassificationReliefFComponent(10, Categoricalx="on")

    Example: c.Categoricalx = "on"

    Data Types: char | string

    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 = featureSelectionClassificationReliefFComponent(10, NumFeatures=5)

    Example: c.NumFeatures = 10

    Data Types: single | double

    Number of nearest neighbors, specified as a positive integer scalar. By default, the component uses the value specified by numNeighbors.

    Example: c = featureSelectionClassificationReliefFComponent(10)

    Example: c.NumNeighbors = 5

    Data Types: single | double

    Prior probabilities for each class, specified as a value in this table.

    ValueDescription
    "empirical"The class prior probabilities are the class relative frequencies. The class relative frequencies are determined by the second data argument of learn.
    "uniform"All class prior probabilities are equal to 1/K, where K is the number of classes.
    numeric vectorA numeric vector with one value for each class. Each element is a class prior probability. The component normalizes the elements such that they sum to 1.
    structure

    A structure S with two fields:

    • S.ClassNames contains a list of the class names.

    • S.ClassProbs contains a vector of corresponding prior probabilities. The component normalizes the elements such that they sum to 1.

    Example: c = featureSelectionClassificationReliefFComponent(10,Prior="uniform")

    Example: c.Prior = "empirical"

    Data Types: single | double | char | string | struct

    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 = featureSelectionClassificationReliefFComponent(10, RelativeScoreThreshold=0.5)

    Example: c.RelativeScoreThreshold = 0.75

    Data Types: single | double

    Distance scaling factor, specified as a numeric positive scalar. For observation i, influence on the predictor weight from its nearest neighbor j is multiplied by e(rank(i,j)/sigma)2. rank(i,j) is the position of the jth observation among the nearest neighbors of the ith observation, sorted by distance.

    Example: c = featureSelectionClassificationReliefFComponent(10, Sigma=20)

    Example: c.Sigma = 50

    Data Types: single | double

    Number of observations to select at random for computing weights, specified as "all" or a positive integer scalar.

    Example: c = featureSelectionClassificationReliefFComponent(10, Updates=25)

    Example: c.Updates = "all"

    Data Types: single | double | char | string

    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 = featureSelectionClassificationReliefFComponent(10, Name="FeatureSelector")

    Example: c.Name = "ReliefFSelector"

    Data Types: char | string

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

    Example: c = featureSelectionClassificationReliefFComponent(10, 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 = featureSelectionClassificationReliefFComponent(10, 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 = featureSelectionClassificationReliefFComponent(10, 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 = featureSelectionClassificationReliefFComponent(10, 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 featureSelectionClassificationReliefFComponent component. Specify to select 3 features using 10 nearest neighbors.

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

    component is a featureSelectionClassificationReliefFComponent 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 = 
      featureSelectionClassificationReliefFComponent with properties:
    
                     Name: "FeatureSelectionClassificationReliefF"
                   Inputs: ["X"    "Y"]
                InputTags: [1 2]
                  Outputs: ["XSelected"    "Scores"]
               OutputTags: [1 NaN]
    
       
    Learnables (HasLearned = true)
        SelectedVariables: ["PetalWidth"    "PetalLength"    "SepalLength"]
            UsedVariables: ["SepalLength"    "SepalWidth"    "PetalLength"    "PetalWidth"]
    
       
    Learn Parameters (locked)
              NumFeatures: 3
             NumNeighbors: 10
    
    
    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
    
        "PetalWidth"    "PetalLength"    "SepalLength"

    Version History

    Introduced in R2026a

    See Also