Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OneClassSVM returns float in predict #8676

Closed
amueller opened this issue Mar 31, 2017 · 7 comments
Closed

OneClassSVM returns float in predict #8676

amueller opened this issue Mar 31, 2017 · 7 comments
Labels

Comments

@amueller
Copy link
Member

@amueller amueller commented Mar 31, 2017

It should return int to be consistent with the rest.

@VathsalaAchar
Copy link
Contributor

@VathsalaAchar VathsalaAchar commented Mar 31, 2017

I'm a new contributor to this repo, could I work on this?

@amueller
Copy link
Member Author

@amueller amueller commented Mar 31, 2017

Hey @VathsalaAchar. Sure, go for it.
Make sure you include a regression test that ensures the correct behavior.

@mppaskov
Copy link
Contributor

@mppaskov mppaskov commented Apr 6, 2017

I am new contributor and I am trying to learn my way around the code.

I think I might have found the problem, in svm.cpp. Although the labels are 'int'
model->label = Malloc(int,nr_class);
in the function predict the value is cast into a double:
double PREFIX(predict_values)(..){ ... return model->label[vote_max_idx];}
I believe that in order to fix that the function definition and all top level calls would have to changed to int.

Does it seem that I am on the right track?

@zxch3n
Copy link

@zxch3n zxch3n commented Apr 6, 2017

@mppaskov I don't think so. I think that we can just overide the predict function and change the type to int.
Because that is how BaseSVC do the job. You can find these lines in predict function:

y = super(BaseSVC, self).predict(X)
return self.classes_.take(np.asarray(y, dtype=np.intp))

BaseSVC's predict function use the predict from BaseLibSVM, and BaseLibSVM is the only super class of OneClassSVM.

@mppaskov
Copy link
Contributor

@mppaskov mppaskov commented Apr 6, 2017

@rem2016 Thank you for clarifying, I think went too deep into the rabbit hole. I was a bit skeptical of changing the underlying API calls in libsvm.
But essentially just applying the same fix from BaseSVC to OneClassSVM. I also believe that this is exactly what @VathsalaAchar implemented in her PR.

@VathsalaAchar
Copy link
Contributor

@VathsalaAchar VathsalaAchar commented Apr 7, 2017

@amueller I made the changes and the PR has been merged, just letting you know in case you want to close this issue.

@jmschrei
Copy link
Member

@jmschrei jmschrei commented Apr 7, 2017

Thanks @VathsalaAchar !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.