grid_search_cv¶
In [ ]:
grid_search_cv(estimator,
param_grid: dict,
input_relation: (str, vDataFrame),
X: list,
y: str,
metric: str = "auto",
cv: int = 3,
pos_label: (int, float, str) = None,
cutoff: float = -1,
training_score: bool = True,
skip_error: bool = False,
print_info: bool = False,)
Computes the k-fold grid search of an estimator.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
estimator | object | ❌ | Vertica estimator having a fit method. |
param_grid | dict | ❌ | Dictionary of the parameters to test. |
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.
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). |
training_score | bool | ✓ | If set to True, the training score will be computed with the validation score. |
skip_error | bool | ✓ | If set to True and an error occurs, it will be displayed and not raised. |
print_info | bool | ✓ | If set to True, prints the model information at each step. |
Returns¶
tablesample : An object containing the result. For more information, see utilities.tablesample.
Example¶
In [1]:
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 grid_search_cv
grid_search_cv(model,
{"tol": [1e-2, 1e-4, 1e-6],
"max_iter": [3, 10, 100],
"solver": ["Newton", "BFGS"]},
input_relation = "public.titanic_clean",
X = ["age", "fare", "parch", "sex", "boat"],
y = "survived",
cv = 3)
Out[1]:
In [2]:
# Adding the train result
grid_search_cv(model,
{"tol": [1e-2, 1e-4, 1e-6],
"max_iter": [3, 10, 100],
"solver": ["Newton", "BFGS"]},
input_relation = "public.titanic_clean",
X = ["age", "fare", "parch", "sex", "boat"],
y = "survived",
cv = 3,
metric = "auc",
training_score = True)
Out[2]:
In [3]:
# Printing the results
grid_search_cv(model,
{"tol": [1e-2, 1e-4, 1e-6],
"max_iter": [3, 10, 100],
"solver": ["Newton", "BFGS"]},
input_relation = "public.titanic_clean",
X = ["age", "fare", "parch", "sex", "boat"],
y = "survived",
cv = 3,
print_info = True)
Out[3]:
