Skip to content

Commit

Permalink
Merge pull request #33 from davidlibland/fix/improve-numerical-stabil…
Browse files Browse the repository at this point in the history
…ity-of-jordan-jaakola-lambda

Fix/improve numerical stability of jordan jaakola lambda
  • Loading branch information
AmazaspShumik committed Jul 27, 2017
2 parents fb15604 + 388a80e commit a9fdcb8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions skbayes/linear_models/bayes_logistic.py
@@ -1,7 +1,7 @@
import numpy as np
from scipy.optimize import fmin_l_bfgs_b
from sklearn.utils.optimize import newton_cg
from scipy.special import expit
from scipy.special import expit, exprel
from scipy.linalg import eigvalsh
from sklearn.utils.multiclass import check_classification_targets
from sklearn.linear_model.base import LinearClassifierMixin, BaseEstimator
Expand Down Expand Up @@ -296,7 +296,8 @@ def _posterior(self, X, Y, alpha0, w0):

def lam(eps):
''' Calculates lambda eps (used for Jaakola & Jordan local bound) '''
return 0.5 / eps * ( expit(eps) - 0.5 )
eps = -abs(eps)
return 0.25 * exprel(eps) / (np.exp(eps) + 1)



Expand Down

0 comments on commit a9fdcb8

Please sign in to comment.