主要内容

equalWidthBinnerComponent

Pipeline component for grouping data into equal-width bins

Since R2026a

    Description

    equalWidthBinnerComponent is a pipeline component that groups data into bins of equal width. The pipeline component uses the functionality of the histcounts function during the learn phase to compute the edges of the bins. The component uses the functionality of the discretize function during the run phase to bin new data.

    Creation

    Description

    component = equalWidthBinnerComponent creates a pipeline component for grouping data into equal-width bins.

    component = equalWidthBinnerComponent(Name=Value) sets writable Properties using one or more name-value arguments. For example, NumBins=10 specifies to create ten equal-width bins.

    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 bins, specified as a positive integer.

    If you do not specify NumBins, then the component automatically calculates how many bins to use based on the values in the first data argument of learn.

    Example: c = equalWidthBinnerComponent(NumBins=10)

    Example: c.NumBins = 5

    Data Types: single | double

    Bin limits, specified as a two-element vector. The first element indicates the first bin edge. The second element indicates the last bin edge. When you specify BinLimits, the component computes bins using only data that falls within the bin limits inclusively.

    This property does not apply to categorical data.

    Example: c = equalWidthBinnerComponent(BinLimits=[1 10])

    Example: c.BinLimits = [0 15]

    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 = equalWidthBinnerComponent(Name="Binner")

    Example: c.Name = "BinData"

    Data Types: char | string

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

    Example: c = equalWidthBinnerComponent(Inputs="Data1")

    Example: c.Inputs = "X"

    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 = equalWidthBinnerComponent(Outputs="BinnedX")

    Example: c.Outputs = "X"

    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 = equalWidthBinnerComponent(InputTags=2)

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

    Example: c = equalWidthBinnerComponent(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.

    Bin edges, returned as a cell array. The first element is the leading edge of the first bin. The last element is the trailing edge of the last bin.

    Data Types: cell

    This property is read-only.

    Names of the variables used by the component to compute the bin edge values, 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 equalWidthBinnerComponent pipeline component. Specify four bins.

    component = equalWidthBinnerComponent(NumBins=4)
    component = 
      equalWidthBinnerComponent with properties:
    
                 Name: "EqualWidthBinner"
               Inputs: "DataIn"
            InputTags: 1
              Outputs: "DataBinned"
           OutputTags: 1
    
       
    Learnables (HasLearned = false)
                Edges: []
        UsedVariables: []
    
       
    Learn Parameters (unlocked)
              NumBins: 4
    
    
    Show all parameters
    

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

    Load the carbig dataset. Create a table containing the Acceleration variable.

    load carbig
    X = table(Acceleration);

    Use the learn object function to bin the acceleration data.

    component = learn(component,X)
    component = 
      equalWidthBinnerComponent with properties:
    
                 Name: "EqualWidthBinner"
               Inputs: "DataIn"
            InputTags: 1
              Outputs: "DataBinned"
           OutputTags: 1
    
       
    Learnables (HasLearned = true)
                Edges: {[5×1 double]}
        UsedVariables: "Acceleration"
    
       
    Learn Parameters (locked)
              NumBins: 4
    
    
    Show all parameters
    

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

    Find the bin edge values.

    edges = component.Edges{1}
    edges = 5×1
         8
        13
        18
        23
        28
    

    Version History

    Introduced in R2026a