Skip to content

LinearDiscriminantAnalysis predict_proba should use softmax #5149

Closed

Description

@amueller

It uses an OVR normalization for multi-class for some unknown (to me) reason.
See #5134.

Activity

  1. added this to the 0.16.2 milestone on Aug 24, 2015
  2. mblondel commented on Aug 26, 2015

    @mblondel
    Member

    AFAIK there are several variants of LDA in the multiclass case.

    @cle1109 @kazemakase Which one do we implement?

  3. cbrnr commented on Aug 26, 2015

    @cbrnr
    Contributor

    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.

  4. mblondel commented on Aug 26, 2015

    @mblondel
    Member

    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?

  5. cbrnr commented on Aug 26, 2015

    @cbrnr
    Contributor

    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?

  6. mblondel commented on Aug 26, 2015

    @mblondel
    Member

    I would have used a = np.exp(a)

    The point is to save a memory allocation by doing the operation in place but I agree this is not big deal.

    Is that what you mean by variant of LDA?

    From C. Bishop's book: "There are now many possible choices of criterion (Fukunaga, 1990)"

    we're computing discriminant functions for each class

    This sounds to me like the current code (compute each proba then normalize) is correct then.

  7. amueller commented on Aug 27, 2015

    @amueller
    MemberAuthor

    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.

  8. modified the milestones: 0.16.2, 0.17 on Sep 8, 2015
  9. modified the milestones: 0.18, 0.17 on Sep 20, 2015
  10. modified the milestones: 0.18, 0.19 on Sep 22, 2016
  11. changed the title [-]LDA predict_proba should use softmax[/-] [+]LinearDiscriminantAnalysis predict_proba should use softmax[/+] on Jun 14, 2017
  12. modified the milestones: 0.20, 0.19 on Jun 14, 2017
  13. modified the milestones: 0.20, 0.21 on Jun 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions