# Hinge Loss for Single Point | Linear Algebra using Python

Linear Algebra using Python | Hinge Loss for Single Point: Here, we are going to learn about the hinge loss for single point and its implementation in Python.
Submitted by Anuj Singh, on June 06, 2020

Hinge Loss is a loss function used in Machine Learning for training classifiers. The hinge loss is a maximum margin classification loss function and a major part of the SVM algorithm.

The hinge loss function is given by:

LossH = max(0,(1-Y*y))

Where, Y is the Label and, y = 𝜭.x

## Python code for Hinge Loss for Single Point

```# Linear Algebra Learning Sequence
# Hinge Loss using linear algebra

import numpy as np

feature = np.array([2,4,4,3,6,9,7,4])
theta = np.array([3,3,3,3,-3,-3,-3,-3])

print('Given point with 8 features : ', feature)
print('Theta : ', theta)

label = 1
y = np.matmul(theta/10, feature)
hingeloss = np.max([0.0, (1 - label*y)])

print("\nThe hinge loss for the given point is :", hingeloss)
```

Output:

```Given point with 8 features :  [2 4 4 3 6 9 7 4]
Theta :  [ 3  3  3  3 -3 -3 -3 -3]

The hinge loss for the given point is : 4.8999999999999995
```

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates