#282 · Machine Learning · Easy
Calculate the margin width of a Support Vector Machine given the weight vector w. The SVM margin width is defined as 2 / ||w||, where ||w|| is the L2 norm of the weight vector.
w
import numpy as np def svm_margin_width(w: np.ndarray) -> float: norm_w = np.linalg.norm(w) return 2.0 / norm_w