You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
LinearDiscriminantAnalysis predict_proba should use softmax #5149
We actually didn't change anything in predict_proba, but looking at the code I see that the implementation is a bit strange (or at least I don't understand why it's done like this). For example, why are there two arguments for np.exp and np.reciprocal?
Anyway, the code is identical to the one in logistic regression, so I guess we're doing the same thing here. Since @MechCoder is working on a fix, we could use it in LDA as well.
For example, why are there two arguments for np.exp and np.reciprocal?
np.exp(a, a) is equal to np.exp(a, out=a). The named argument is not supported with older versions of NumPy.
Anyway, the code is identical to the one in logistic regression, so I guess we're doing the same thing here
The way to compute predict_proba may depend on the variant of multiclass LDA we're using. Since there are several variants, the code may be wrong or it may be correct.
@amueller What makes you think softmax is the right way to compute predict_proba here? Any reference?
np.exp(a, a) is equal to np.exp(a, out=a). The named argument is not supported with older versions of NumPy.
I see. I would have used a = np.exp(a), which is unambiguous because I don't have to look up the arguments.
Regarding the LDA variant, we're computing discriminant functions for each class. The class with the highest value will be selected for a particular sample (this is inherited from LinearClassifierMixin). Is that what you mean by variant of LDA?
I don't have my bishop here, we should check the reference.
It just seems like a very odd formula.
I was assuming that this is just p(y|x) under the probabilistic model where p(x|y) is gaussian with shared covariance.
Activity
mblondel commentedon Aug 26, 2015
AFAIK there are several variants of LDA in the multiclass case.
@cle1109 @kazemakase Which one do we implement?
cbrnr commentedon Aug 26, 2015
We actually didn't change anything in
predict_proba, but looking at the code I see that the implementation is a bit strange (or at least I don't understand why it's done like this). For example, why are there two arguments fornp.expandnp.reciprocal?Anyway, the code is identical to the one in logistic regression, so I guess we're doing the same thing here. Since @MechCoder is working on a fix, we could use it in LDA as well.
mblondel commentedon Aug 26, 2015
np.exp(a, a)is equal tonp.exp(a, out=a). The named argument is not supported with older versions of NumPy.The way to compute predict_proba may depend on the variant of multiclass LDA we're using. Since there are several variants, the code may be wrong or it may be correct.
@amueller What makes you think softmax is the right way to compute predict_proba here? Any reference?
cbrnr commentedon Aug 26, 2015
I see. I would have used
a = np.exp(a), which is unambiguous because I don't have to look up the arguments.Regarding the LDA variant, we're computing discriminant functions for each class. The class with the highest value will be selected for a particular sample (this is inherited from
LinearClassifierMixin). Is that what you mean by variant of LDA?mblondel commentedon Aug 26, 2015
The point is to save a memory allocation by doing the operation in place but I agree this is not big deal.
From C. Bishop's book: "There are now many possible choices of criterion (Fukunaga, 1990)"
This sounds to me like the current code (compute each proba then normalize) is correct then.
amueller commentedon Aug 27, 2015
I don't have my bishop here, we should check the reference.
It just seems like a very odd formula.
I was assuming that this is just p(y|x) under the probabilistic model where p(x|y) is gaussian with shared covariance.
[-]LDA predict_proba should use softmax[/-][+]LinearDiscriminantAnalysis predict_proba should use softmax[/+]