We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There are several bugs in script glmnet_python / cvlognet.py when using ptype='auc' for binary classification. Fix them by the following!
#========================= # Helper functions #========================= def auc_mat(y, prob, weights = None): if type(weights) == type(None) or len(weights) == 0: weights = scipy.ones([y.shape[0], 1]) wweights = weights*y wweights = wweights.flatten('F') wweights = scipy.reshape(wweights, [wweights.size]) ny= y.shape[0] a = scipy.zeros([ny]) b = scipy.ones([ny]) yy = scipy.hstack((a, b)) pprob = scipy.hstack((prob,prob)) result = auc(yy, pprob, wweights) return(result) #========================= def auc(y, prob, w): if len(w) == 0: mindiff = scipy.amin(scipy.diff(scipy.unique(prob))) pert = scipy.random.uniform(0, mindiff/3, prob.size) t, rprob = scipy.unique(prob + pert, return_inverse = True) n1 = scipy.sum(y, keepdims = True) n0 = y.shape[0] - n1 u = scipy.sum(rprob[y == 1]) - n1*(n1 + 1)/2 result = u/(n1*n0) else: op = scipy.argsort(prob) y = y[op] w = w[op] cw = scipy.cumsum(w) w1 = w[y == 1] cw1 = scipy.cumsum(w1) wauc = scipy.sum(w1*(cw[y == 1] - cw1)) sumw = cw1[-1] sumw = sumw*(cw[-1] - sumw) result = wauc/sumw return(result) #=========================
if grouped == True and ptype != 'auc': cvob = cvcompute(cvraw, weights, foldid, nlams) cvraw = cvob['cvraw'] weights = cvob['weights'] N = cvob['N']
The text was updated successfully, but these errors were encountered:
No branches or pull requests
There are several bugs in script glmnet_python / cvlognet.py when using ptype='auc' for binary classification.
Fix them by the following!
The text was updated successfully, but these errors were encountered: