MCA¶
In [ ]:
MCA(name: str)
Creates a MCA (multiple correspondence analysis) object using the Vertica PCA algorithm on the data. It uses the property that the MCA is a PCA applied to a complete disjunctive table. The input relation is transformed to a TCDT (transformed complete disjunctive table) before applying the PCA.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
name | str | ❌ | Name of the model to be stored in the database. |
Attributes¶
After object creation, all the parameters become attributes of the object. The model will also create extra attributes when fitting the model:
| Name | Type | Description |
|---|---|---|
components_ | tablesample | The principal components. |
explained_variance_ | tablesample | The explained variance of the singular values. |
cos2_ | tablesample | The cos2 (Quality of Representation) of the different input variables to each components. |
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_contrib | Draws a decomposition contribution plot of the input dimension. |
| plot_cos2 | Draws a MCA cos2 plot of the two input dimensions. |
| plot_circle | Draws a decomposition circle. |
| plot_scree | Draws a decomposition scree plot. |
| plot_var | Draws a MCA variables plot. |
| score | Returns the decomposition Score on a dataset for each trasformed column. |
| set_params | Sets the parameters of the 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 built-in Vertica functions. |
| transform | Applies the model on a vDataFrame. |
Example¶
In [5]:
from verticapy.learn.decomposition import MCA
model = MCA(name = "public.mca_titanic")
display(model)
In [6]:
from verticapy.datasets import load_titanic
titanic = load_titanic()
# Computing the Transformed Completely Disjontive Table before fitting the model
tcdt = titanic[["survived", "pclass", "sex"]].cdt()
model.fit(tcdt)
model.plot_scree()
Out[6]:
In [8]:
model.plot_var(method="cos2")
Out[8]:
