-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid model introspection by requiring users to provide a function that defines a model instance #199
Comments
The docs could probably specify that the model factory function is provided with an object whose properties are the same as the keyword arguments to domain = Domain(
K = (1, 3, 5, 7, 11),
leafsize = (5, 10, 15)
)
function make_model(params)
Pipeline(
encoder = ContinuousEncoder(),
estimator = KNNRegressor(K=params.K, leafsize=params.leafsize)
)
end
tunable_model = TunedModel(make_model, domain; strategy=Grid()) or like this: tunable_model = (
TunedModel(domain; strategy=Grid()) do params
Pipeline(
encoder = ContinuousEncoder(),
estimator = KNNRegressor(K=params.K, leafsize=params.leafsize)
)
end
) or this: tunable_model = (
TunedModel(domain; strategy=Grid()) do params
(; K, leafsize) = params
Pipeline(
encoder = ContinuousEncoder(),
estimator = KNNRegressor(K=K, leafsize=leafsize)
)
end
) or this: tunable_model = (
TunedModel(domain; strategy=Grid()) do params
Pipeline(
encoder = ContinuousEncoder(),
estimator = KNNRegressor(; params...)
)
end
) |
@CameronBieganek Thanks for pitching in with this idea. Here are a few drawbacks that come to mind. I wonder what you think about them:
|
@ablaom I will try to respond to your questions soon, but for now I just want to point out a couple advantages of this approach. Fields of model types are no longer public:The current hyperparameter tuning interface requires that the fields of model types be public API, otherwise the user wouldn't know the correct
|
I think I mentioned this idea a few years ago on a different thread, but I never gave the proposal its own issue.
This is a breaking change, but I think it would provide a cleaner interface for hyperparameter tuning, and it would also address #174.
The idea is that instead of specifying the hyperparameters that need to be tuned with a quoted expression like
:(estimator.leafsize)
, the user can simply provide a function that creates a new model. Here is one way that it could work:I've prefixed the feature names with an underscore to emphasize that what matters is that the keyword argument names in
make_model
match the keyword argument names inDomain
. The actual names are arbitrary.The downside to requiring the user defined function to use keyword arguments is that you can't really use
do
-notation inTunedModel
, because as far as I can tell there is no way to define an anonymous function with keyword arguments by usingdo
-notation. So, an alternative interface would be to require the user defined function to take a single positional argument with property destructuring, like this:This can then be expressed with
do
-notation as follows:I believe this interface is generic enough to work for any hyperparameter tuning strategy.
The text was updated successfully, but these errors were encountered: