Skip to content

Commit ea98c29

Browse files
qinhanmin2014agramfort
authored andcommitted
MNT Simply gradient computation of sigmoid calibration (scikit-learn#14439)
1 parent a0cfcef commit ea98c29

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

sklearn/calibration.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,8 @@ def objective(AB):
452452

453453
def grad(AB):
454454
# gradient of the objective function
455-
E = np.exp(AB[0] * F + AB[1])
456-
P = 1. / (1. + E)
457-
TEP_minus_T1P = P * (T * E - T1)
455+
P = expit(-(AB[0] * F + AB[1]))
456+
TEP_minus_T1P = T - P
458457
if sample_weight is not None:
459458
TEP_minus_T1P *= sample_weight
460459
dA = np.dot(TEP_minus_T1P, F)

0 commit comments

Comments
 (0)