For linear kernel, the decision boundary is y = w * x + b, the distance from point x to the decision boundary is y/||w||.
y = svc.decision_function(x)
w_norm = np.linalg.norm(svc.coef_)
dist = y / w_norm
For non-linear kernels, there is no way to get the absolute distance. But you can still use the result of decision_funcion
as relative distance.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…