I am having an issue with a section of code I am running. It's purpose is to find the vector that minimizes a function via scipy.opimize's minimize function with a constraint.
However, I keep getting thrown the following error
line 495, in minimize
constraints, callback=callback, **options) line 378, in _minimize_slsqp
fx = func(x), line 292, in function_wrapper
return function(*(wrapper_args + args), TypeError: 'numpy.ndarray' object is not callable
I am a little confused as to what I am doing wrong. The following code contains the function to be minimised and the constrain function.
def constraint1(w):
goal = 1
for i in range(w.shape[0]):
goal - w[i]
return goal
def lasso_var(w, *args):
var = w.T.dot(args[0]).dot(w)+args[1]*sum(abs(w))
return var
con1 = {'type': 'eq', 'fun': constraint1}
from scipy.optimize import minimize
sol = minimize(lasso_var(w, *(train_sig, 5)),\
x0=w_equal,\
constraints=con1)
where w is a vector and train_sig is a matrix.
Many Thanks for any aid you can give.