Scipy.minimize - "typeerror: Numpy.float64' Object Is Not Callable Running"
Solution 1:
Short answer
It should instead be:
opts = scipy.minimize(a, len(symbols) * [1. / len(symbols),], args=(w,), method='SLSQP', bounds=bound, constraints=constraint)
Details
a(data, w) is not a function, it's a function call. In other words a(data, w) effectively has the value and type of the return value of the function a. minimize needs the actual function without the call (ie without the parentheses (...) and everything in-between), as its first parameter.
From the scipy.optimize.minimize docs:
scipy.optimize.minimize(fun, x0, args=(), method=None, jac=None, hess=None, hessp=None, bounds=None, constraints=(), tol=None, callback=None, options=None)
...
fun : callable
The objective function to be minimized. Must be in the form f(x, *args). The optimizing argument, x, is a 1-D array of points, and args is a tuple of any additional fixed parameters needed to completely specify the function.
...
args : tuple, optional
Extra arguments passed to the objective function...
So, assuming w is fixed (at least with respect to your desired minimization), you would pass it to minimize via the args parameter, as I've done above.
Solution 2:
You're not passing the function, but the evaluated result to minimize.
opts = scipy.minimize(a, len(symbols) * [1. / len(symbols),], method = 'SLSQP', bounds = bound, constraints = constraint, args = (data,w))
Should work.
Edit: Fixed stupid syntax error.
Post a Comment for "Scipy.minimize - "typeerror: Numpy.float64' Object Is Not Callable Running""