cross_validate¶
In [ ]:
cross_validate(estimator,
input_relation: (str, vDataFrame),
X: list,
y: str,
metric: (str, list) = "all",
cv: int = 3,
pos_label: (int, float, str) = None,
cutoff: float = -1,
show_time: bool = True,
training_score: bool = False,)
Computes the k-fold cross validation of an estimator.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
estimator | object | ❌ | Vertica estimator having a fit method. |
input_relation | str / vDataFrame | ❌ | Input Relation. |
X | list | ❌ | List of the predictor columns. |
y | str | ❌ | Response Column. |
metric | str / list | ✓ | Metric used to do the model evaluation. It can also be a list of metrics.
For Classification:
For Regression:
|
cv | int | ✓ | Number of folds. |
pos_label | int / float / str | ✓ | The main class to be considered as positive (classification only). |
cutoff | float | ✓ | The model cutoff (classification only). |
show_time | bool | ✓ | If set to True, the time and the average time will be added to the report. |
training_score | bool | ✓ | If set to True, the training score will be computed with the validation score. |
Returns¶
tablesample : An object containing the result. For more information, see utilities.tablesample.
Example¶
In [3]:
from verticapy.learn.linear_model import LogisticRegression
model = LogisticRegression(name = "public.LR_titanic",
tol = 1e-4,
max_iter = 100,
solver = 'Newton')
from verticapy.learn.model_selection import cross_validate
cross_validate(model,
input_relation = "public.titanic_clean",
X = ["age", "fare", "parch", "sex", "boat"],
y = "survived",
cv = 3)
Out[3]:
In [5]:
# Adding the train result
res_test, res_train = cross_validate(
model,
input_relation = "public.titanic_clean",
X = ["age", "fare", "parch", "sex", "boat"],
y = "survived",
cv = 3,
metric = "auc",
training_score = True)
display(res_test)
In [6]:
display(res_train)
