Hinge Loss for SVM
Instance-Based, Kernel & Probabilistic Methods DS practice problem on Onlearn.
Difficulty: medium.
Topics: Understanding the Hinge Loss function in Support Vector Machines, Hinge Loss formulation, Vectorized dot product operations, Broadcasting in NumPy, Support Vector Machine geometric interpretation, Non-differentiable points in loss surfaces, Optimization Theory, Linear Algebra, Statistical Learning Theory, Supervised Learning, Numerical Computing, Margin Maximization, Convex Optimization, Loss Functions, Decision Boundaries, Regularization.
Implement a function 'hinge loss(X, y, w, b)' that calculates the average Hinge Loss for a linear SVM. The formula for a single sample is L = max(0, 1 y i (w · x i + b)). The function should return the mean loss across all samples.