Extract decision boundary with scikit-learn linear SVM

后端 未结 3 2132
忘了有多久
忘了有多久 2021-02-10 01:15

I have a very simple 1D classification problem: a list of values [0, 0.5, 2] and their associated classes [0, 1, 2]. I would like to get the classification boundaries between th

3条回答
  •  时光取名叫无心
    2021-02-10 01:56

    I had the same question and eventually found the solution in the sklearn documentation.

    Given the weights W=svc.coef_[0] and the intercept I=svc.intercept_ , the decision boundary is the line

    y = a*x - b
    

    with

    a = -W[0]/W[1]
    b = I[0]/W[1]
    

提交回复
热议问题