vastorbit.machine_learning.metrics.aic_score¶
- vastorbit.machine_learning.metrics.aic_score(y_true: str, y_score: str, input_relation: Annotated[str | VastFrame, ''], k: int = 1) float¶
Returns the AIC score.
- 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.
Examples
We should first import vastorbit.
import vastorbit as vo
Let’s create a small dataset that has:
true value
predicted value
data = vo.VastFrame( { "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 vastorbit.machine_learning.metrics import aic_score
Now we can conveniently calculate the score:
aic_score( y_true = "y_true", y_score = "y_pred", input_relation = data, )
It is also possible to directly compute the score from the VastFrame:
data.score( y_true = "y_true", y_score = "y_pred", metric = "aic", )
Note
vastorbit uses simple SQL queries to compute various metrics. You can use the
set_option()function with thesql_onparameter to enable SQL generation and examine the generated queries.See also
VastFrame.score(): Computes the input ML metric.