2

Given a Python callable that returns a fitness measurement (0.0=horrible, 0.5=ok, 1.0=perfect) and a description of its parameters (type=bool|int|float|nominal, min, max), what are robust implementations of parameter optimizers that can find the combination of parameters that get the fitness measure as high as possible? I'm not looking for an exhaustive guaranteed global optimum. An approximation would be fine.

I've seen scipy's optimize module referenced a lot, but also scikit-learn's gridsearch. What's the practical difference between these two? What are other options?

4
  • i have used gridsearch a lot. are you looking to optimize the parameters of some components in your pipeline? for example gridsearch will allow you to create pipelines with feature selectors and classifiers. Commented Nov 3, 2015 at 17:12
  • @AbtPst, I have an image-processing pipeline, and for each image, I've manually set the parameters that give the optimal/desired output. Now I'm trying to find a single set of parameters that will work well for "most" images. I'm basically just trying to generalize my hand-tuned parameters. Commented Nov 3, 2015 at 20:38
  • please take a look here stackoverflow.com/questions/33353228/… Commented Nov 3, 2015 at 20:44
  • does my answer look like something you want? Commented Nov 3, 2015 at 20:44

2 Answers 2

2

Given a parameter space and the task to find an optimum, gridsearch is probably the easiest thing you can do: Discretize the parameter space and just check all combinations by brute-force. Return the parameter combination that yielded the best result.

This works, but as you can imagine, this does not scale well. For high dimensional optimization problems this is simply not feasible.

Strategies to improve here depend on what additional information you have. In the optimal case you optimize a smooth and differentiable function. In this case you can use numerical optimization.

In numerical optimization routines you exploit the fact that the gradient of a function always points upward. So if you want to increase the function value, you simply follow the gradient a little bit and you will always improve, as long as the gradient is not zero.

This powerful concept is exploited in most of scipy's routines. This way you can optimize high-dimensional functions by exploiting additional information you get about the neighborhood of your current position.

So if you do not have a smooth and differential function, scipy's numerical routines cannot be used.

Note that exploiting the information in the neighborhood of your current parameter vector can be used in non-smooth optimization as well. Basically you do the same thing: You check a window around your current estimate and try to improve by finding a better value in that window.

Sign up to request clarification or add additional context in comments.

Comments

0

In most simple terms, scipy.optimize mostly does gradient-based optimization, sklearn.model_selection.GridSearchCV does brute-force search over all parameter combinations, and a Bayesian optimizer like sambo.SamboSearchCV, which is model-based, does much fewer evaluations—hopefully only the most enlightening ones.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.