Skip to content

MRG Refactor liblinear bindings - #1143

Merged
larsmans merged 4 commits into
scikit-learn:masterfrom
larsmans:refactor-liblinear
Sep 16, 2012
Merged

larsmans merged 4 commits into
scikit-learn:masterfrom
larsmans:refactor-liblinear

Conversation

@larsmans

Copy link
Copy Markdown
Member

Here's yet another refactoring of the liblinear bindings. I've replaced all the prediction code in LinearSVC and LogisticRegression with equivalent NumPy code. Highlights:

  • no more copying of X at predict time
  • no more unchecked malloc at predict time
  • -4000 lines of C code
  • simpler handling of coef_ and intercept_

Liblinear bindings removed from LinearSVC and LogisticRegression
prediction code in favor of NumPy code.

* no more copying of X at predict time
* no more unchecked malloc at predict time
* -4000 lines of C code
* simpler handling of coef_ and intercept_

Also, support symbolic class names and classes_ on both estimators.
Restore code to be slightly closer to upstream (still not possible to
run with the original library, though).

Comment out some more code that we don't use to reduce build time.
@agramfort

Copy link
Copy Markdown
Member

beautiful ! tests pass + example render nicely !

@amueller

Copy link
Copy Markdown
Member

Thanks a lot for the refactoring! Awesome 👍

@amueller

Copy link
Copy Markdown
Member

Does this make predict and predict_proba faster?

@amueller

Copy link
Copy Markdown
Member

Closes #388.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweet! I was working on putting this into the common tests but progress kind of stalled. Can you do SVC next ;)

@larsmans

Copy link
Copy Markdown
Member Author

Closes #388.

Not exactly, as I didn't touch the LibSVM bindings.

@amueller

Copy link
Copy Markdown
Member

Hm I thought that was about the linear case... guess it is not... or also for linear case of the SVC? But than that seems like more code, not less...

@larsmans

Copy link
Copy Markdown
Member Author

I'm not sure. I might have a look at SVC as well, or I might not. As for the speed, I didn't thoroughly benchmark it, but it didn't seem any slower and it should take less memory.

@mblondel

Copy link
Copy Markdown
Member

pairwise_kernels could be used in SVC.decision_function and SVC.predict. This needs to allocate an n_samples x n_sv array though. Also dense_output=True in safe_sparse_dot is not implemented efficiently at the moment.

@larsmans

Copy link
Copy Markdown
Member Author

I'm not going to touch SVC in this PR. One learner at a time :)

@amueller

Copy link
Copy Markdown
Member

good idea ;)

@larsmans

Copy link
Copy Markdown
Member Author

Alright, I think my work on this one is done. Any final opinions? @pprett perhaps?

(I'm currently returning Fortran arrays from predict_proba. I think that after this PR and #1141 are merged, it's time to refactor the linear classifiers by introducing a LinearClassifierMixin, so we can fix that then.)

@mblondel

Copy link
Copy Markdown
Member

+1 for tackling SVC in a dedicated PR.

@amueller

Copy link
Copy Markdown
Member

@larsmans I think you are right and in this case we can use train, we should only avoid it elsewhere ;)

@amueller

Copy link
Copy Markdown
Member

+1 for merge :)

larsmans added a commit that referenced this pull request Sep 16, 2012
Refactor liblinear bindings: rewrote prediction code in Python
@larsmans
larsmans merged commit 6f13021 into scikit-learn:master Sep 16, 2012
@amueller

Copy link
Copy Markdown
Member

awesome, thanks :)

@larsmans

Copy link
Copy Markdown
Member Author

More coming up :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants