Loading...

verticapy.machine_learning.memmodel.decomposition.PCA.transform_sql#

PCA.transform_sql(X: list | ndarray) list[str]#

Transforms and returns the SQL needed to deploy the PCA model.

Parameters#

X: ArrayLike

The names or values of the input predictors.

Returns#

list

SQL code.

Examples#

Import the required module.

from verticapy.machine_learning.memmodel.decomposition import PCA

We will use the following attributes:

principal_components = [
    [0.4, 0.5],
    [0.3, 0.2],
]


mean = [0.1, 0.3]

Let’s create a model.

model_pca = PCA(principal_components, mean)

Create a dataset.

data = [[4, 5]]

Let’s use the following column names:

cnames = ['col1', 'col2']

Get the SQL code needed to deploy the model.

model_pca.transform_sql(cnames)
Out[7]: 
['(col1 - 0.1) * 0.4 + (col2 - 0.3) * 0.3',
 '(col1 - 0.1) * 0.5 + (col2 - 0.3) * 0.2']

Note

Refer to PCA for more information about the different methods and usages.