Skip to content

implement (Linear)SVC predict and decision_function in pure Python #388

Closed

Description

@mblondel

LinearSVC and SVC's predict and decision_function could easily be implemented in pure python.

Advantages:

  • Reduce binding size
  • Avoid the creation of liblinear and libsvm's internal models from numpy arrays / sparse matrices at each call

Disadvantage:

  • Less memory efficient if predict is implemented as the argmax of decision_function

This should also solve the problem that decision_function is not implemented in sparse.SVC.

In any case, we should probably do a little benchmark to make sure we don't loose too much in runtime speed.

Activity

  1. ogrisel commented on Oct 9, 2011

    @ogrisel
    Member

    +1 for the benchmark and the reduced binding size if little perf decrease (say under 20%).

  2. fabianp commented on Oct 10, 2011

    @fabianp
    Member

    Nice idea. +1.

  3. tehf0x commented on Dec 5, 2011

    @tehf0x

    +1 for decision_function in sparse.SVC, I was about to file a bug on that, but I guess I won't unless someone thinks it's worth it.

  4. amueller commented on Sep 13, 2012

    @amueller
    Member

    You mean also for the kernelized case?
    Hm guess it is not so hard, but either we have to do compute the whole kernel matrix (on the support vectors) at one, which is very memory inefficient, or we have to do it for each vector separately, which will probably have a big looping overhead. So do it in cython using some cython distance functions?

  5. amueller commented on Dec 8, 2017

    @amueller
    Member

    the linear cases do this by now, the kernelized cases seem rather tricky. closing. Feel free to reopen if anyone wants to work on it

  6. mohamed-ali commented on Mar 30, 2018

    @mohamed-ali
    Contributor

    @amueller @jnothman I think this issue can be closed thanks to PR #1143.

  7. jnothman commented on Apr 1, 2018

    @jnothman
    Member

    Thanks

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

    EnhancementModerate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions