Skip to content

RangeScaler

The RangeScaler transforms column values by scaling each value to a given range.

Parent type: InvertibleTableTransformer

Parameters:

Name Type Description Default
selector union<List<String>, String?> The list of columns used to fit the transformer. If None, all numeric columns are used. null
min Float The minimum of the new range after the transformation 0.0
max Float The maximum of the new range after the transformation 1.0

Examples:

pipeline example {
    val table = Table({"a": [1, 2, 3]});
    val scaler = RangeScaler(selector = "a").fit(table);
    val transformedTable = scaler.transform(table);
    // transformedTable = Table({"a": [0.0, 0.5, 1.0]});
    val originalTable = scaler.inverseTransform(transformedTable);
    // originalTable = Table({"a": [1, 2, 3]});
}
Stub code in RangeScaler.sdsstub

class RangeScaler(
    selector: union<List<String>, String, Nothing?> = null,
    @PythonName("min_") const min: Float = 0.0,
    @PythonName("max_") const max: Float = 1.0,
) sub InvertibleTableTransformer {
    /**
     * The minimum of the new range after the transformation.
     */
    attr min: Float
    /**
     * The maximum of the new range after the transformation.
     */
    attr max: Float

    /**
     * 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: RangeScaler

    /**
     * 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: RangeScaler, transformedTable: Table)
}

isFitted

Whether the transformer is fitted.

Type: Boolean

max

The maximum of the new range after the transformation.

Type: Float

min

The minimum of the new range after the transformation.

Type: Float

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 RangeScaler The fitted transformer.
Stub code in RangeScaler.sdsstub

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

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 RangeScaler The fitted transformer.
transformedTable Table The transformed table.
Stub code in RangeScaler.sdsstub

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

inverseTransform

Undo the learned transformation as well as possible.

Column order and types may differ from the original table. Likewise, some values might not be restored.

Note: The given table is not modified.

Parameters:

Name Type Description Default
transformedTable Table The table to be transformed back to the original version. -

Results:

Name Type Description
originalTable Table The original table.
Stub code in InvertibleTableTransformer.sdsstub

@Pure
@PythonName("inverse_transform")
fun inverseTransform(
    @PythonName("transformed_table") transformedTable: Table
) -> originalTable: 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