Loading...

verticapy.machine_learning.metrics.anova_table#

verticapy.machine_learning.metrics.anova_table(y_true: str, y_score: str, input_relation: str | vDataFrame, k: int = 1) TableSample#

Computes the ANOVA table.

Parameters#

y_true: str

Response column.

y_score: str

Prediction.

input_relation: SQLRelation

Relation to use for scoring. This relation can be a view, table, or a customized relation (if an alias is used at the end of the relation). For example: (SELECT … FROM …) x

k: int, optional

Number of predictors.

Returns#

TableSample

ANOVA table.

Examples#

We should first import verticapy.

import verticapy as vp

Let’s create a small dataset that has:

  • true value

  • predicted value

data = vp.vDataFrame(
    {
        "y_true": [1, 1.5, 3, 2, 5],
        "y_pred": [1.1, 1.55, 2.9, 2.01, 4.5],
    }
)

Next, we import the metric:

from verticapy.machine_learning.metrics import anova_table

Now we can conveniently compute the ANOVA table:

anova_table(
    y_true  = "y_true",
    y_score = "y_pred",
    input_relation = data,
)

Out[4]: 
None            Df        SS                     MS                    F   \\
Regression       1    7.2626                 7.2626    79.92589875275128   \\
Residual         3    0.2726    0.09086666666666667                        \\
Total            4      10.0                                               \\
None                          p_value  
Regression      0.0002917833677198816  
Residual                               
Total                                  
Rows: 1-3 | Columns: 6

Note

VerticaPy uses simple SQL queries to compute various metrics. You can use the set_option() function with the sql_on parameter to enable SQL generation and examine the generated queries.

See also

vDataFrame.score() : Computes the input ML metric.