v Describe An Array - Machine Learning

Describe An Array

Preliminaries

# Load library
import numpy as np

Create Matrix

# Create matrix
matrix = np.array([[1, 2, 3, 4],
                   [5, 6, 7, 8],
                   [9, 10, 11, 12]])

View Shape

# View number of rows and columns
matrix.shape
(3, 4)

View Total Elements

# View number of elements (rows * columns)
matrix.size
12

View Number Of Dimensions

# View number of dimensions
matrix.ndim
2