What is the difference between OneVsRestClassifier with SVC and SVC with decision_function_shape='ovr'?

前端 未结 1 1007
情深已故
情深已故 2021-02-04 04:57

I thought it should be the same, but for method decision_function() I get different results. And SVC with only decision_function_shape=\'ovr\' is reall

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-04 05:37

    I got some clarification on the documentation of LinearSVC in the See also heading, where SVC is mentioned.

    SVC

    Implementation of Support Vector Machine classifier using libsvm:

    ....

    ....

    Furthermore SVC multi-class mode is implemented using one vs one scheme while LinearSVC uses one vs the rest. It is possible to implement one vs the rest with SVC by using the sklearn.multiclass.OneVsRestClassifier wrapper.

    ....

    Also, SVC delegates all the training to the underlying libsvm library, which handles the multi-class case as 'OvO' (even if the decision_function_shape = 'ovr').

    Its mentioned in the issue @delusionX mentioned that decision_function_shape is just for compatibility with scikit API. Its most probably, that all other estimators handle the multi-class as OvR and so when SVC is used in combination with other things, (Like for example in a Pipeline, GridSearchCV, Or wrappers like OneVsRestClassifier) returning a OvO decision function breaks the working of others. But I could not find that written explicitly anywhere.

    Fun fact: OneVsOneClassifier also returns a decision function which confirms with the shape of OvR.

    0 讨论(0)
提交回复
热议问题