Thanks to visit codestin.com
Credit goes to github.com

Skip to content

OneClassSVM returns float in predict #8676

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

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
Bug Easy Well-defined and straightforward way to resolve

Comments

@amueller
Copy link
Member

It should return int to be consistent with the rest.

@amueller amueller added Bug Easy Well-defined and straightforward way to resolve Need Contributor labels Mar 31, 2017
@VathsalaAchar
Copy link
Contributor

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

@amueller
Copy link
Member Author

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

@mppaskov
Copy link
Contributor

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 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 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

@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 commented Apr 7, 2017

Thanks @VathsalaAchar !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Easy Well-defined and straightforward way to resolve
Projects
None yet
Development

No branches or pull requests

5 participants