SelfExplainML / PiML-Toolbox

PiML (Python Interpretable Machine Learning) toolbox for model development & diagnostics
https://selfexplainml.github.io/PiML-Toolbox
Apache License 2.0
912 stars 109 forks source link

High-code grid search examples? #39

Open jphall663 opened 1 year ago

jphall663 commented 1 year ago

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?

ZebinYang commented 1 year ago

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)
jphall663 commented 1 year ago

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