Getting An Error "could Not Broadcast Input Array From Shape (252,4) Into Shape (4)" In Optimization
I a relatively new to python scipy library. I was trying to use the scipy.optimize to find the maximum value of the sharpe() function in the following code def sharpe(dr, wts):
Solution 1:
I think you need to swap the arguments in your definition of the sharpe
function. It is defined as sharpe(dr,wts)
but then it looks like you call minimize as sharpe(wts,dr)
based on your use of args
. Edit: I have just seen that this is pointed out in the above comments!
Post a Comment for "Getting An Error "could Not Broadcast Input Array From Shape (252,4) Into Shape (4)" In Optimization"