주요 콘텐츠

sparseFilterComponent

Pipeline component for feature extraction using sparse filtering

Since R2026a

    Description

    sparseFilterComponent is a pipeline component that performs feature extraction using sparse filtering. The pipeline component uses the functionality of the sparsefilt function during the learn phase to extract features from the data. The component uses the functionality of the transform function during the run phase to transform new data into the extracted features.

    Creation

    Description

    component = sparseFilterComponent creates a pipeline component for feature extraction using sparse filtering.

    component = sparseFilterComponent(Name=Value) sets writeable Properties using one or more name-value arguments. For example, NumFeatures=5 specifies to extract five 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 to extract, specified as a positive integer scalar.

    If you do not specify the NumFeatures value, the software extracts all features.

    Example: c = sparseFilterComponent(NumFeatures=5)

    Example: c.NumFeatures = 10

    Data Types: single | double

    Relative convergence tolerance on the gradient norm, specified as a positive numeric scalar. This gradient is the gradient of the objective function.

    Example: c = sparseFilterComponent(GradientTolerance=1e-4)

    Example: c.GradientTolerance = 1e-8

    Data Types: single | double

    Transformation weights that initialize the optimization, specified as a p-by-NumFeatures numeric matrix, where p is the number of features in the first input argument of learn used by the component.

    If you do not specify the InitialTransformWeights value, the software uses a matrix of normally distributed random numbers.

    Example: c = sparseFilterComponent(InitialTransformWeights=randn(100,20))

    Example: c.InitialTransformWeights = 2*randn(100,20)

    Data Types: single | double

    Maximum number of iterations, specified as a positive integer scalar.

    Example: c = sparseFilterComponent(IterationLimit=1e6)

    Example: c.IterationLimit = 1e4

    Data Types: single | double

    L2 regularization coefficient value for the transform weight matrix, specified as a nonnegative numeric scalar.

    Example: c = sparseFilterComponent(Lambda=0.1)

    Example: c.Lambda = 0.5

    Data Types: single | double

    Flag to standardize the predictor data before performing feature extraction, specified as a numeric or logical 0 (false) or 1 (true). A value of 1 indicates to center and scale each numeric predictor.

    Example: c = sparseFilterComponent(Standardize=true)

    Example: c.Standardize = false

    Data Types: single | double | logical

    Absolute convergence tolerance on the step size, specified as a positive numeric scalar.

    Example: c = sparseFilterComponent(StepTolerance=1e-4)

    Example: c.StepTolerance = 1e-8

    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 = sparseFilterComponent(Name="Filter")

    Example: c.Name = "SparseFiltering"

    Data Types: char | string

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

    Example: c = sparseFilterComponent(Inputs="X")

    Example: c.Inputs = "X1"

    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 = sparseFilterComponent(Outputs="ReducedX")

    Example: c.Outputs = "ReducedX1"

    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 = sparseFilterComponent(InputTags=0)

    Example: c.InputTags = 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 = sparseFilterComponent(OutputTags=0)

    Example: c.OutputTags = 1

    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.

    Learned sparse filtering model, returned as a SparseFiltering model object.

    This property is read-only.

    Names of the variables used by the component to extract features, returned as a string array. The variables correspond to columns in the 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 pipeline component that performs feature extraction using sparse filtering. Specify to extract 3 features.

    component = sparseFilterComponent(NumFeatures=3)
    component = 
    
      sparseFilterComponent with properties:
    
                        Name: "SparseFilter"
                      Inputs: "DataIn"
                   InputTags: 1
                     Outputs: "DataOut"
                  OutputTags: 1
    
       
    Learnables (HasLearned = false)
        SparseFilteringModel: []
               UsedVariables: []
    
       
    Learn Parameters (unlocked)
                 NumFeatures: 3
    
    
    Show all parameters
    

    component is a sparseFilterComponent object that contains two learnables: SparseFilteringModel and UsedVariables. The properties remain 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 create a sparse filtering model from the predictor data X.

    component = learn(component,X)
    component = 
    
      sparseFilterComponent with properties:
    
                        Name: "SparseFilter"
                      Inputs: "DataIn"
                   InputTags: 1
                     Outputs: "DataOut"
                  OutputTags: 1
    
       
    Learnables (HasLearned = true)
        SparseFilteringModel: [1×1 SparseFiltering]
               UsedVariables: ["SepalLength"    "SepalWidth"    "PetalLength"    "PetalWidth"]
    
       
    Learn Parameters (locked)
                 NumFeatures: 3
    
    
    Show all parameters

    The SparseFilteringModel and UsedVariables properties are nonempty, and the HasLearned property is set to true.

    In the sparse filtering model, find the feature transformation weights used for extracting features.

    weights = component.SparseFilteringModel.TransformWeights
    weights =
    
       -0.6548   -0.5253   -0.8233
       -0.5402   -0.4524   -3.2801
        3.0857    2.3349    3.5047
        2.5450    3.3118   -1.4569

    Version History

    Introduced in R2026a