SVC and LinearSVC 异同

Question:

  1. what's different between SVC and LinearSVC in python sklearn library?

  2. Does the SVC(kernel='linear') have the same result on LinearSVC()

  3. if we want to model the linear kernel how do we choose?

Reply:

  1. What is the difference between SVC and SVM in scikit-learn?
    *The SVM module (SVC, NuSVC, etc) is a wrapper around the libsvm library and supports different kernels while LinearSVC is based on liblinear and only supports a linear kernel.

  2. Under what parameters are SVC and LinearSVC in scikit-learn equivalent?
    Personally I consider LinearSVC one of the mistakes of sklearn developers - this class is simply not a linear SVM.
    To sum up: **LinearSVC is not linear SVM, do not use it if do not have to.

    **

  3. When should one use LinearSVC or SVC?
    Between SVC and LinearSVC, one important decision criterion is that LinearSVC tends to be faster to converge the larger the number of samples is. This is due to the fact that the linear kernel is a special case, which is optimized for in Liblinear, but not in Libsvm.

  4. From documentation, you can also see the theory and math:
    https://scikit-learn.org/stable/modules/svm.html#svc

posted @ 2021-12-07 20:32  Kin_Zhang  阅读(62)  评论(0)    收藏  举报