Giter Site home page Giter Site logo

API Design about ksvm.jl HOT 24 CLOSED

evizero avatar evizero commented on July 24, 2024
API Design

from ksvm.jl.

Comments (24)

Evizero avatar Evizero commented on July 24, 2024

Note, I didn't want to touch SVM.jl, simply because I'd have to delete the whole code anyway. Beside inefficient implementations, there are a few strange things going on in that package, such as convergences being defines as iter >= maxiter, checking if a float is exactly 0.0 without tolerance, or storing a scalar as a vector of identical scalars.

from ksvm.jl.

lindahua avatar lindahua commented on July 24, 2024

This would become a great package. Your efforts will be appreciated by the community.

In terms of incorporating kernels, I think it may be a good idea to just write kernel based prediction functions. Not completely sure whether it may eventually work out, but I think it is good to try.

When this package matures, we should consider merge this and SVM.jl in certain way -- people tend to search for SVM.jl first instead of KSVM.jl. It seems like that SVM has not been actively updated for a while (except for changes to make it work with Julia 0.4).

cc @johnmyleswhite

from ksvm.jl.

Evizero avatar Evizero commented on July 24, 2024

To really make it clean, I will have to make some additions to EmpiricalRisks.

For example I currently abuse the L1 / L2 regularizer to specify if I use L1-SVM or L2-SVM. However, in the later case that L1/L2 actually refers to the (squared) hinge loss and not the penalty. So given the same parameters, my new solver does a very different thing than the others. Also the C in SVM is not the same as the lambda in the usual case, but 1 / lambda.

Bottom line: I will implement the squared Hinge Loss

I'll submit a PR as soon as I get to it. Do you have any objections right away?

from ksvm.jl.

johnmyleswhite avatar johnmyleswhite commented on July 24, 2024

I think it would be good to let that SVM.jl name go vacant for a month or two to make people realize the package is dead. After that, it would be pretty easy to move this new over to that name.

from ksvm.jl.

Evizero avatar Evizero commented on July 24, 2024

I agree with that. There is no rush to claim that name. This package needs a lot of work before I am willing to Tag it.

There still need to be ...

  • A version that fits the bias (efficiently) as well
  • A special implementation for sparse matrices
  • ~~~At least the stochastic version dual coordinate descent for the LinearSVM~~~ (This will have to wait until I come up with a good general solution in SupervisedLearning.jl)
  • A one-vs-all version for dual coordinate descent
  • At least one algorithm for linear support-vector regression
  • Hard tests that really proof this package does what it pretends to do
  • An implementation of Platt's method for computing probabilities
  • A clean way to access the support vectors as user
  • Kernels and SMO for Kernel-based problems
  • Benchmarks against LibLinear and LibSVM respectively

Can anyone think of anything important I should add to that list? If you know people that have a stake or strong opinion on SVMs, please add them to the conversation. (Maybe @tbreloff ?)

from ksvm.jl.

johnmyleswhite avatar johnmyleswhite commented on July 24, 2024

If you're looking for work, some performance comparisons against LibSVM would be very compelling.

from ksvm.jl.

Evizero avatar Evizero commented on July 24, 2024

That's a good idea. added.

I did look at that code. It is quite impressive. I'm hopefull we'll get within a factor of 10

from ksvm.jl.

Evizero avatar Evizero commented on July 24, 2024

I added sparse matrix support to the list (at least for linear SVM). I think that is the single most important usecase for linear SVMs anyhow, so I will tackle that soon.

Does anyone have a specific suggestion for what package(s) to use for the sparse stuff, or is Base ok? The associated issues are kind of confusion regarding the current best practice

from ksvm.jl.

johnmyleswhite avatar johnmyleswhite commented on July 24, 2024

The only meaningful sparse support I know of is in Base and it's only for CSC format. Eventually that will be moved out to a package, but the timeline on that is very unclear.

from ksvm.jl.

Evizero avatar Evizero commented on July 24, 2024

Thanks. Turns out the inner structure of the SparseMatrixCSC type is perfect for dual coordinate descent and I was able to really abuse this nicely

from ksvm.jl.

Evizero avatar Evizero commented on July 24, 2024

Well, so the first informal benchmarks (that are simply an adoption of here ) hints on a 2000x20000 matrix that for this version of the dual cd algorithm, that my implementation is at least somewhat on par with Pythons Scikit learn. The algorithm I implemented is pretty much the same as the one LibLinear (and thus Scikit-learn) uses, however it is neither online nor does it use anything like shrinking at this point. That being said I compare in the tests against Scikit-learns and get the same accuracy to at least three decimal places on those datasets.

So for this very informal benchmark I use scikit-learns LinearSVC which is just a liblinear wrapper, and I set the same settings for iterations and tolerance

python: 45.3 sec
julia - dense version: 22.5 sec
julia - sparse version: 28.5 sec

note that the generated training data is not sparse at all but very dense (the SVMLight file is 1 GB), thus I am actually surprised that the sparse implementation is competitive for this particular example.

I will implement a formal benchmark and check for significance, but that will have to wait a little until the other tasks are done

Edit: There is a good chance though that these numbers are overly optimistic, because I am not yet sure if I do the convergence check in the same manner as LibLinear. For this dataset I got .93 acc and scitlearn .94, which makes me suspect that my implementation simply exited earlier

from ksvm.jl.

johnmyleswhite avatar johnmyleswhite commented on July 24, 2024

Very impressive work, even if the numbers need further revision.

from ksvm.jl.

Evizero avatar Evizero commented on July 24, 2024

About half an hour ago I have read a discussion on licensing and derivative work and that got me a little paranoid.

First of all I did look at the SVM.jl code, even though I didn't take it as a reference (I implemented the algorithm just according to the paper). That being said, it's fair to say that the package did influence me. But that shouldn't be a problem, as everything should be OK if I giving credit for inspiration here, which I will gladly do.

But there might be an issue. I aim to make this package available under MIT. However, I just remembered that I did browse over the liblinear code, mainly to get a feel of how complex it is to implement something like this in C. Nonetheless, I technically looked at it for a minute or so. Since I am implementing the same algorithm which should give the same result, I guess one could argue that I am in a bit of a grey area here from a license standpoint.

What am I to do now? Can I still make this package MIT licensed, or do I have to remove dual coordinate descent and implement an other algorithm while being really careful to not stumble on any code that implements it?

Edit: I didn't realize you were the author of SVM.jl. Shows how ignorant I can be sometimes. Sorry if I stepped on your toes. I am pretty new to the open source movement, and did not give the licensing issues as much attention as I probably should have.

from ksvm.jl.

johnmyleswhite avatar johnmyleswhite commented on July 24, 2024

What is the liblinear license?

A good rule of thumb is that you can never read GPL code unless you're writing a GPL library. Reading BSD code is harmless, although you still need to give attribution.

-- John

Sent from my iPhone

On Sep 18, 2015, at 8:27 AM, Christof Stocker [email protected] wrote:

About half an hour ago I have read a discussion on licensing and derivative work and that got me a little paranoid.

First of all I did look at the SVM.jl code, even though I didn't take it as a reference (I implemented the algorithm just according to the paper). That being said, it's fair to say that the package did influence me. But that shouldn't be a problem, as everything should be OK if I giving credit for inspiration here, which I will gladly do.

But there might be an issue. I aim to make this package available under MIT. However, I just remembered that I did browse over the liblinear code, mainly to get a feel of how complex it is to implement something like this in C. Nonetheless, I technically looked at it for a minute or so. Since I am implementing the same algorithm which should give the same result, I guess one could argue that I am in a bit of a grey area here from a license standpoint.

What am I to do now? Can I still make this package MIT licensed, or do I have to remove dual coordinate descent and implement an other algorithm while being really careful to not stumble on any code that implements it?


Reply to this email directly or view it on GitHub.

from ksvm.jl.

Evizero avatar Evizero commented on July 24, 2024

modified BSD. So I guess I am not screwed? Man, should have known better. I didn't even get anything out of looking at it anyway.

Thank you, that's good thing to know. I'll simply never look at any related code again. Thankfully I haven't encountered any frustrating implementation issue thus far. might have ended up looking in the wrong place for answers

from ksvm.jl.

johnmyleswhite avatar johnmyleswhite commented on July 24, 2024

Modified BSD == 2-clause or 3-clause? Either are fine.

The licensing situation is very complicated and we're being a little paranoid just to avoid any dangers for corporate users. But public domain, MIT and BSD code are all fine (except for 4-clause BSD). APL is ok, although you probably have to release your code as APL if you base anything on an APL library. But that's arguably better for some corporate users anyway.

from ksvm.jl.

Evizero avatar Evizero commented on July 24, 2024

It's 3-clause. I should have really spend time on this issue before-hand. Didn't think simply browsing over it could cause me issues. I was planning to look at the code of a GPL licensed package, but luckily I didn't get around to it yet (I am sure my IP traces and such can prove that). Dodged a bullet there. I'll avoid anything code-related like the plague from now on.

You don't happen to know how I can properly give attribution for looking at the BSD code? I don't seem to find anything that describes this situation.

Also (you probably missed it since I edited my post before), I came to realize that you are the author of SVM.jl, which I did look at very closely. How can I properly give you attribution? This is my naive try to do so

from ksvm.jl.

johnmyleswhite avatar johnmyleswhite commented on July 24, 2024

Usually I do things like this: https://github.com/JuliaLang/julia/blob/e97588db65f590d473e7fbbb127f30c01ea94995/src/support/asprintf.c

Since SVM is MIT, I'm not worried about attribution, but you could do the same thing as the BSD example above.

from ksvm.jl.

Evizero avatar Evizero commented on July 24, 2024

Thank you, I will happily do that.

Thank you for your very quick and helpful advise, I got really paranoid and frustrated there for a second. I am just glad that I can continue this project with a clean conscience.

from ksvm.jl.

johnmyleswhite avatar johnmyleswhite commented on July 24, 2024

Welcome to the world that the GPL has created. :)

from ksvm.jl.

Evizero avatar Evizero commented on July 24, 2024

So, I hope this is appropriate: link

from ksvm.jl.

johnmyleswhite avatar johnmyleswhite commented on July 24, 2024

That's more than enough

from ksvm.jl.

Evizero avatar Evizero commented on July 24, 2024

This package will soon be at a usable stage, so I have started sketching out a very rough draft for the README. Since you both provide pretty good examples in Regression.jl and SVM.jl respectively I have been thinking of adapting those.

Are you both okay with how I assign you credit for the examples in the README?

from ksvm.jl.

johnmyleswhite avatar johnmyleswhite commented on July 24, 2024

Works for me

from ksvm.jl.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.