I'm following the example given in scipy's optimize documentation to do brute-force optimization on a function with 3 parameters.
This is the function I wish to optimize:
def entropy_of_hyperplane(z):
w0, w1, b = z
# do some calculations..
return -1 * ent
To find the global minimum of this function using grid-serach, I do:
def find_max_entropy_hyperplane(X):
# grid-search on all the possible w in R^2 , b in R
# and calculate the entropy of each
rranges = (slice(0, 2, 0.05), slice(0, 2, 0.05), slice(-4, 4, 0.25)) # ranges for w0, w1, b
resbrute = optimize.brute(entropy_of_hyperplane, rranges, full_output=True,
finish=optimize.fmin)
w0, w1, b = resbrute[0]
print(w0, w1, b)
And the result is:
w0 = 1.56; w1 = 1.1; b = 1842.73906893
What is going on here? How is the optimal value of b outside the range I specified? I can't understand this behavior. Any help appreciated!