Loading...

vastorbit.machine_learning.vast.preprocessing.Scaler.transform

Scaler.transform(vdf: Annotated[str | VastFrame, ''] = None, X: Annotated[str | list[str], 'STRING representing one column or a list of columns'] | None = None) VastFrame

Applies the model on a VastFrame.

Parameters:
  • vdf (SQLRelation, optional) – Input VastFrame. You can also specify a customized relation, but you must enclose it with an alias. For example: (SELECT 1) x is valid whereas (SELECT 1) and SELECT 1 are invalid.

  • X (SQLColumns, optional) – list of the input VastColumn.

Returns:

object result of the model transformation.

Return type:

VastFrame

Examples

We import vastorbit:

import vastorbit as vo

For this example, we will use a dummy dataset.

data = vo.VastFrame(
    {
        "values": [1, 1.01, 1.02, 1.05, 1.024],
    }
)

Let’s import the model:

from vastorbit.machine_learning.vast import Scaler

Then we can create the model:

model = Scaler(method = "zscore")

We can now fit the model:

model.fit(data)

To get the scaled dataset, we can use the transform method. Let us transform the data:

model.transform(data)
123
values
Decimal(38, 10)
10.1903683025
21.7371107604
3-1.2373939663
4-0.642493021
5-0.0475920756
Rows: 1-5 | Column: values | Type: decimal(38, 10)

Similarly, you can perform the inverse transform to get the original features using:

model.inverse_transform(data_transformed)

The variable data_transformed is the scaled dataset.

Important

For this example, a specific model is utilized, and it may not correspond exactly to the model you are working with. To see a comprehensive example specific to your class of interest, please refer to that particular class.