verticapy.machine_learning.memmodel.preprocessing.StandardScaler¶
- class verticapy.machine_learning.memmodel.preprocessing.StandardScaler(mean: Annotated[list | ndarray, 'Array Like Structure'], std: Annotated[list | ndarray, 'Array Like Structure'])¶
InMemoryModelimplementation of standardScaler.Parameters¶
- mean: ArrayLike
Model’s features averages.
- std: ArrayLike
Model’s features standard deviations.
Note
StandardScalerare defined entirely by their attributes. For example,mean, andstdof feature(s) define aStandardScalermodel.Attributes¶
Attributes are identical to
Scaler.Examples¶
Initalization
Import the required module.
from verticapy.machine_learning.memmodel.preprocessing import StandardScaler
A StandardScaler model is defined by
meanand ``std``values. In this example, we will use the following:mean = [0.4, 0.1] std = [0.5, 0.2]
Let’s create a
StandardScalermodel.model_sts = StandardScaler(mean, std)
Create a dataset.
data = [[0.45, 0.17]]
Making In-Memory Transformation
Use
transform()method to do transformation.model_sts.transform(data) Out[6]: array([[0.1 , 0.35]])
Deploy SQL Code
Let’s use the following column names:
cnames = ['col1', 'col2']
Use
transform_sql()method to get the SQL code needed to deploy the model using its attributes.model_sts.transform_sql(cnames) Out[8]: ['(col1 - 0.4) / 0.5', '(col2 - 0.1) / 0.2']
Hint
This object can be pickled and used in any in-memory environment, just like SKLEARN models.
- __init__(mean: Annotated[list | ndarray, 'Array Like Structure'], std: Annotated[list | ndarray, 'Array Like Structure']) None¶
Methods
__init__(mean, std)Returns the model attributes.
set_attributes(**kwargs)Sets the model attributes.
transform(X)Transforms and applies the
Scalermodel to the input matrix.Transforms and returns the SQL needed to deploy the
Scaler.Attributes
Must be overridden in child class