Lorah Attkins
Lorah Attkins

Reputation: 5856

How to optimize a black box function in Python?

I have a function to optimize, which I can't get the derivative or Hessian or Jacobian out of (hence the "black box" in the title). Say my function looks like this:

def my_fun(some_int, some_other_int, some_string):
    return float(some_int + some_other_int + len(some_string))

note that I only perform the cast to show that the function returns a floating point number.

The search space / constraints / bounds (or however you call it) would be:

some_int = [1..10] # int interval
some_other_int = [1, 2, 3] # int discrete
some_string = ["methodA", "methodB", "methodC"] #discrete

How should I formulate the problem in python? This is what I've searched so far:

Any thoughts?

Upvotes: 6

Views: 8355

Answers (1)

v.thorey
v.thorey

Reputation: 2087

You could use an hyperparameter optimization package such as https://github.com/Dreem-Organization/benderopt/

It supports the different type of your parameters.

Upvotes: 3

Related Questions