verticapy.machine_learning.model_selection.hp_tuning.gen_params_grid¶
- verticapy.machine_learning.model_selection.hp_tuning.gen_params_grid(estimator: VerticaModel, nbins: int = 10, max_nfeatures: int = 3, lmax: int = -1, optimized_grid: int = 0) dict[str, Any]¶
Generates the estimator grid.
Parameters¶
- estimator: object
Vertica estimator with a fit method.
- nbins: int, optional
Number of bins used to discretize numerical features.
- max_nfeatures: int, optional
Maximum number of features used to compute Random Forest, PCA…
- lmax: int, optional
Maximum length of the parameter grid.
- optimized_grid: int, optional
If set to 0, the randomness is based on the input parameters. If set to 1, the randomness is limited to some parameters while others are picked based on a default grid. If set to 2, there is no randomness and a default grid is returned.
Returns¶
- dict
Dictionary of parameters.
Examples¶
Let’s take
LogisticRegressionas an example model:from verticapy.machine_learning.vertica import LogisticRegression model = LogisticRegression()
Now, we can find the parameter grid quite conveniently using:
from verticapy.machine_learning.model_selection import gen_params_grid gen_params_grid(model, lmax = 10) Out[4]: [{'tol': 1e-06, 'max_iter': 1000, 'penalty': 'enet', 'solver': 'cgd', 'C': 4.501, 'l1_ratio': 0.601}, {'tol': 1e-08, 'max_iter': 1000, 'penalty': 'enet', 'solver': 'cgd', 'C': 0.501, 'l1_ratio': 0.401}, {'tol': 1e-08, 'max_iter': 500, 'penalty': 'enet', 'solver': 'cgd', 'C': 3.001, 'l1_ratio': 0.101}, {'tol': 1e-06, 'max_iter': 500, 'penalty': 'l1', 'solver': 'cgd', 'C': 3.501}, {'tol': 1e-08, 'max_iter': 1000, 'penalty': 'enet', 'solver': 'cgd', 'C': 4.001, 'l1_ratio': 0.501}, {'tol': 0.0001, 'max_iter': 500, 'penalty': 'l2', 'solver': 'bfgs', 'C': 3.001}, {'tol': 1e-06, 'max_iter': 1000, 'penalty': 'enet', 'solver': 'cgd', 'C': 4.001, 'l1_ratio': 0.001}, {'tol': 0.0001, 'max_iter': 500, 'penalty': 'enet', 'solver': 'cgd', 'C': 3.001, 'l1_ratio': 0.801}, {'tol': 1e-06, 'max_iter': 100, 'penalty': 'enet', 'solver': 'cgd', 'C': 0.501, 'l1_ratio': 0.501}, {'tol': 1e-08, 'max_iter': 1000, 'penalty': 'enet', 'solver': 'cgd', 'C': 0.501, 'l1_ratio': 0.901}]
Note
The function automatically detects the parameters from any VerticaPy model, and then creates a grid based on the generic value range.
See also
parameter_grid(): Generates alistof the different combinations of input parameters.