Loading...

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 LogisticRegression as 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': 100,
  'penalty': 'enet',
  'solver': 'cgd',
  'C': 2.501,
  'l1_ratio': 0.701},
 {'tol': 0.0001,
  'max_iter': 1000,
  'penalty': 'enet',
  'solver': 'cgd',
  'C': 1.501,
  'l1_ratio': 0.501},
 {'tol': 1e-08,
  'max_iter': 1000,
  'penalty': 'enet',
  'solver': 'cgd',
  'C': 0.001,
  'l1_ratio': 0.001},
 {'tol': 0.0001,
  'max_iter': 1000,
  'penalty': 'enet',
  'solver': 'cgd',
  'C': 2.501,
  'l1_ratio': 0.501},
 {'tol': 1e-06,
  'max_iter': 100,
  'penalty': 'enet',
  'solver': 'cgd',
  'C': 4.501,
  'l1_ratio': 0.801},
 {'tol': 1e-06,
  'max_iter': 1000,
  'penalty': 'enet',
  'solver': 'cgd',
  'C': 4.001,
  'l1_ratio': 0.101},
 {'tol': 0.0001,
  'max_iter': 100,
  'penalty': 'enet',
  'solver': 'cgd',
  'C': 0.501,
  'l1_ratio': 0.001},
 {'tol': 1e-06,
  'max_iter': 1000,
  'penalty': 'enet',
  'solver': 'cgd',
  'C': 0.001,
  'l1_ratio': 0.801},
 {'tol': 1e-06,
  'max_iter': 500,
  'penalty': 'l2',
  'solver': 'newton',
  'C': 4.501},
 {'tol': 0.0001,
  'max_iter': 100,
  'penalty': 'l2',
  'solver': 'bfgs',
  'C': 4.001}]

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 a list of the different combinations of input parameters.