PiML-Toolbox icon indicating copy to clipboard operation
PiML-Toolbox copied to clipboard

High-code grid search examples?

Open jphall663 opened this issue 2 years ago • 2 comments

Is it possible to make a high-code example for random or Cartesian grid search? I could not find one after a brief search of the doc ... please let me know if there is an example already.

Is there a preferred approach for grid search in PiML that I am missing?

jphall663 avatar May 31 '23 13:05 jphall663

The PiML built-in models follow the sklearn style, and the sklearn's grid-search API can be used directly. For example, to tune the L1 and L2 regularization strengths, the following codes can be used:

from piml.models import GLMRegressor
from sklearn.model_selection import GridSearchCV

train_x, train_y, train_sample_weight = exp.get_data(train=True)

grid = GridSearchCV(GLMRegressor(), param_grid={"l1_regularzation": [0, 0.3],
                                                "l2_regularzation": [0, 0.3]})
grid.fit(train_x, train_y)

ZebinYang avatar Jun 02 '23 01:06 ZebinYang

Ok - this is helpful. I'm going to leave open for a moment until I can make an example or some notes myself!

jphall663 avatar Jun 09 '23 19:06 jphall663