Calculate the angle between two vectors in NumPy (Python)

You can get the angle between two vectors in NumPy (Python) as follows.

import numpy as np
import numpy.linalg as LA

a = np.array([1, 2])
b = np.array([-5, 4])

inner = np.inner(a, b)
norms = LA.norm(a) * LA.norm(b)

cos = inner / norms
rad = np.arccos(np.clip(cos, -1.0, 1.0))
deg = np.rad2deg(rad)

print(rad)  # 1.35970299357215
print(deg)  # 77.9052429229879

NumPy Vector

NumPy Tutorial