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

[FEA] Multi-class classification in SVM #959

Closed
tfeher opened this issue Aug 12, 2019 · 2 comments · Fixed by #3092
Closed

[FEA] Multi-class classification in SVM #959

tfeher opened this issue Aug 12, 2019 · 2 comments · Fixed by #3092
Labels
? - Needs Triage Need team to review and classify feature request New feature or request

Comments

@tfeher
Copy link
Contributor

tfeher commented Aug 12, 2019

Is your feature request related to a problem? Please describe.
Currently only binary classification is supported.

Describe the solution you'd like
Implement multi-class classifier.

Additional context
Watch out for parameter layout #958

@tfeher tfeher added ? - Needs Triage Need team to review and classify feature request New feature or request labels Aug 12, 2019
@beckernick
Copy link
Member

This would be awesome addition 👍

@alxhrzg
Copy link

alxhrzg commented Nov 27, 2020

Just for someone looking for and intermediate solution, you can wrap e.g. SVC in sklearns OneVsRestClassifier wrapper such as:
For some background:

from sklearn.metrics import make_scorer
from sklearn.multiclass import OneVsRestClassifier
from sklearn.metrics import accuracy_score

accuracy_typed = make_scorer(lambda y_true, y_pred: accuracy_score(
    y_true.astype(int), y_pred.astype(int)
), greater_is_better=True)


SVC_params = {
    'estimator__C': [0.1, 1, 10, 100, 1000],  
    'estimator__gamma': [1, 0.1, 0.01, 0.001, 0.0001], 
    'estimator__kernel': ['rbf']
}  

SVC_Grid = GridSearchCV(
    OneVsRestClassifier(SVC(verbose=2)), 
    SVC_params, 
    refit = True, 
    verbose = 3,
    scoring=accuracy_typed
) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
? - Needs Triage Need team to review and classify feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants