I'm trying to use a particular cost function (based on doubling rate of wealth) for a classification problem, and the solution works well in MATLAB. See https://github.com/acmyers/compareCostFXs
When I try to do this in Python 2.7.6 I don't get any errors, but it only returns zeros for the theta values.
Here is the cost function and optimization method I've used in Python:
def costFunctionDRW(theta, X, y): # Initialize useful values m = len(y) # Marginal probability of acceptance marg_pA = sum(y)/m # Marginal probability of rejection marg_pR = 1 - marg_pA # ============================================================= pred = sigmoid(np.dot(X,theta)) final_wealth_individual = (pred/marg_pA)*y + ((1-pred)/marg_pR)*(1-y) final_wealth = np.prod(final_wealth_individual) final_wealth = -final_wealth return final_wealth result = scipy.optimize.fmin(costFunctionDRW, x0=initial_theta, \ args=(X_array, y_array), maxiter=1000, disp=False, full_output=True )
Any advice would be much appreciated!