v Invert A Matrix - Machine Learning

Invert A Matrix

Preliminaries

# Load library
import numpy as np

Create Matrix

# Create matrix
matrix = np.array([[1, 4],
                   [2, 5]])

Invert Matrix

# Calculate inverse of matrix
np.linalg.inv(matrix)
array([[-1.66666667,  1.33333333],
       [ 0.66666667, -0.33333333]])