Skip to content

Discretizer

The Discretizer bins continuous data into intervals.

Parent type: TableTransformer

Parameters:

Name Type Description Default
binCount Int The number of bins to be created. 5
selector union<List<String>, String?> The list of columns used to fit the transformer. If None, all numeric columns are used. null

Examples:

pipeline example {
    val table = Table({"a": [1, 2, 3, 4]});
    val discretizer = Discretizer(binCount = 2, selector = "a").fit(table);
    val transformedTable = discretizer.transform(table);
    // Table({"a": [0, 0, 1, 1]})
}
Stub code in Discretizer.sdsstub

class Discretizer(
    @PythonName("bin_count") const binCount: Int = 5,
    selector: union<List<String>, String, Nothing?> = null
) sub TableTransformer where {
    binCount >= 2
} {
    /**
     * The number of bins to be created.
     */
    @PythonName("bin_count") attr binCount: Int

    /**
     * Learn a transformation for a set of columns in a table.
     *
     * This transformer is not modified.
     *
     * @param table The table used to fit the transformer.
     *
     * @result fittedTransformer The fitted transformer.
     */
    @Pure
    fun fit(
        table: Table
    ) -> fittedTransformer: Discretizer

    /**
     * Learn a transformation for a set of columns in a table and apply the learned transformation to the same table.
     *
     * **Note:** Neither this transformer nor the given table are modified.
     *
     * @param table The table used to fit the transformer. The transformer is then applied to this table.
     *
     * @result fittedTransformer The fitted transformer.
     * @result transformedTable The transformed table.
     */
    @Pure
    @PythonName("fit_and_transform")
    fun fitAndTransform(
        table: Table
    ) -> (fittedTransformer: Discretizer, transformedTable: Table)
}

binCount

The number of bins to be created.

Type: Int

isFitted

Whether the transformer is fitted.

Type: Boolean

fit

Learn a transformation for a set of columns in a table.

This transformer is not modified.

Parameters:

Name Type Description Default
table Table The table used to fit the transformer. -

Results:

Name Type Description
fittedTransformer Discretizer The fitted transformer.
Stub code in Discretizer.sdsstub

@Pure
fun fit(
    table: Table
) -> fittedTransformer: Discretizer

fitAndTransform

Learn a transformation for a set of columns in a table and apply the learned transformation to the same table.

Note: Neither this transformer nor the given table are modified.

Parameters:

Name Type Description Default
table Table The table used to fit the transformer. The transformer is then applied to this table. -

Results:

Name Type Description
fittedTransformer Discretizer The fitted transformer.
transformedTable Table The transformed table.
Stub code in Discretizer.sdsstub

@Pure
@PythonName("fit_and_transform")
fun fitAndTransform(
    table: Table
) -> (fittedTransformer: Discretizer, transformedTable: Table)

transform

Apply the learned transformation to a table.

Note: The given table is not modified.

Parameters:

Name Type Description Default
table Table The table to which the learned transformation is applied. -

Results:

Name Type Description
transformedTable Table The transformed table.
Stub code in TableTransformer.sdsstub

@Pure
fun transform(
    table: Table
) -> transformedTable: Table