PCA¶
In [ ]:
PCA(name: str,
n_components: int = 0,
scale: bool = False,
method: str = "lapack")
Creates a PCA (Principal Component Analysis) object using the Vertica PCA function.
Parameters¶
Name | Type | Optional | Description |
---|---|---|---|
name | str | ❌ | Name of the model to be stored in the database. |
n_components | int | ✓ | The number of components to keep in the model. If this value is not provided, all components are kept. The maximum number of components is the number of non-zero singular values returned by the internal call to SVD. This number is less than or equal to SVD (number of columns, number of rows). |
scale | bool | ✓ | A Boolean value that specifies whether to standardize the columns during the preparation step. |
method | str | ✓ | The method to use to calculate PCA.
|
Attributes¶
After the object creation, all the parameters become attributes. The model will also create extra attributes when fitting the model:
Name | Type | Description |
---|---|---|
components_ | tablesample | The principal components. |
explained_variance_ | tablesample | The singular values explained variance. |
mean_ | tablesample | The information about columns from the input relation used for creating the PCA model. |
input_relation | str | Training relation. |
X | list | List of the predictors. |
Methods¶
Name | Description |
---|---|
deploySQL | Returns the SQL code needed to deploy the model. |
deployInverseSQL | Returns the SQL code needed to deploy the inverse model (PCA ** -1). |
drop | Drops the model from the Vertica DB. |
fit | Trains the model. |
get_attr | Returns the model attribute. |
get_params | Returns the model Parameters. |
inverse_transform | Applies the inverse model on a vDataFrame. |
plot | Draws a decomposition scatter plot. |
plot_circle | Draws a decomposition circle. |
plot_scree | Draws a decomposition scree plot. |
score | Returns the decomposition Score on a dataset for each trasformed column. |
set_params | Sets the parameters of the model. |
to_memmodel | Converts a specified Vertica model to a memModel model. |
to_python | Returns the Python code needed to deploy the model without using built-in Vertica functions. |
to_sql | Returns the SQL code needed to deploy the model without using Vertica built-in functions. |
transform | Applies the model on a vDataFrame. |
Example¶
In [36]:
from verticapy.learn.decomposition import PCA
model = PCA(name = "public.pca_iris")
display(model)