Discretize continuous features with the Binning component

Updated at:

Feature discretization groups continuous data into a finite number of intervals, or bins. To do this, PAI provides the Binning and Data Conversion Module components. Use the Binning component to define bin boundaries for continuous features, and then use the Data Conversion Module to transform the original values into discrete bin indices.

Prerequisites

Procedure

  1. Go to the Machine Learning Designer page.

    1. Log on to the PAI console.

    2. In the left-side navigation pane, click Workspaces. On the Workspaces page, click the name of the workspace that you want to manage.

    3. In the left-side navigation pane, choose Model Training > Visualized Modeling (Designer).

  2. Create an empty pipeline and go to the pipeline page. For more information, see Create a Custom Pipeline.

    Set the following parameters:

    • Pipeline Name: Enter Discretize Continuous Features by Using the Binning Component.

    • Description: Enter Use the Binning component provided by PAI to discretize continuous features.

    • Visibility: Select Visible to Me.

  3. Build the pipeline.

    1. From the component list on the left, drag the Read Table component under Source/Destination to the canvas.

    2. From the component list on the left, drag the Binning and Data Conversion Module components under Financial Sector to the canvas.

    3. Connect the components to form a pipeline as shown in the following figure.特征离散化实验

  4. Configure the component parameters.

    1. Click the Read Table component on the canvas. In the right-side panel, configure the data source for the pipeline.

      Tab

      Parameter

      Description

      Table selection

      Table Name

      Enter pai_online_project.iris_data.

      Partition

      The Partition checkbox is unavailable because this table is not partitioned.

      Field information

      Source table field information

      After you set the Table Name, the system automatically populates the Source table field information.

    2. Click the Binning component on the canvas. In the right-side panel, configure the parameters. Configure only the following parameters and keep the default values for the rest.

      Tab

      Parameter

      Description

      Field Settings

      Feature columns

      Select the f1, f2, f3, and f4 columns.

      Parameters

      Number of bins

      Set the value to 10. This discretizes the continuous features into 10 intervals.

      Binning method

      Valid values: Equal Frequency, Equal Width, and Auto Binning. To use Auto Binning, the data source must contain a label field and the scenario must be binary classification. This topic uses Equal Frequency as an example.

    3. Click the Data Conversion Module component on the canvas. In the right-side panel, configure the parameters. Configure only the following parameters and keep the default values for the rest.

      Tab

      Parameter

      Description

      Field Settings

      Columns not converted

      Select the type column. This column is passed through without changes.

      Data conversion type

      Select Index.

  5. Click the Run icon image at the top of the canvas.

  6. View the pipeline results.

    1. After the pipeline is run, right-click the Data Conversion Module component on the canvas and choose View Data > Output from the shortcut menu to view the discretization results. The result table contains five columns: type, f1, f2, f3, and f4. The type column contains class labels, such as Iris-setosa, and the feature values in the f1 to f4 columns are converted to discrete integers.

    2. Right-click the Binning component on the canvas and select Binning from the shortcut menu.

    3. Click a feature name, such as f1, to view its binning details. The details dialog box has two tabs: List and Charts. The List tab displays a binning table and a toolbar with operations that include Save, Copy All, Merge, Split, Move Down, Move Up, Expand, Undo, Redo, View Constraints, and Export Bins and Constraints. The right-side Custom Binning panel allows you to customize bins using Specify Bins or Specify Boundaries. You can also set various constraints, such as ascending, descending, or Weight of Evidence (WOE) order.

    4. Click the Charts tab to view the binning results in a chart.分箱结果的图表展示

Related documents