JuliaAI / MLJTuning.jl

Hyperparameter optimization algorithms for use in the MLJ machine learning framework
MIT License
66 stars 12 forks source link

Skipping parts of search space? #189

Closed MilesCranmer closed 11 months ago

MilesCranmer commented 11 months ago

Hi,

There are some parts of search space where my model will fail to return a usable result, and this triggers a BoundError at the prediction step. The parts of search space where this will occur is not clearly defined (and is probabilistic), so clean! is not applicable. I am wondering how I may wrap the tuning with a try-catch so that certain errors are simply returned as an infinite loss, rather than breaking the entire tuning and exiting?

Thanks! Miles

MilesCranmer commented 11 months ago

I guess it might be cleaner to just have the model not throw an error, but just return an uninitialized array in case of error?

OkonSamuel commented 11 months ago

Hi,

There are some parts of search space where my model will fail to return a usable result, and this triggers a BoundError at the prediction step. The parts of search space where this will occur is not clearly defined (and is probabilistic), so clean! is not applicable. I am wondering how I may wrap the tuning with a try-catch so that certain errors are simply returned as an infinite loss, rather than breaking the entire tuning and exiting?

Thanks! Miles

Can you give an example code snippet.

OkonSamuel commented 11 months ago

I guess it might be cleaner to just have the model not throw an error, but just return an uninitialized array in case of error?

Yeah. You should be able to handle all that during the call to fit.

MilesCranmer commented 11 months ago

Thanks for the quick response!

After thinking about it more, I may just have the predict step return an uninitialized array in case of incorrect fits, as it seems something unique to SRRegressor (in case the search can't find a valid expression, for example).