Title: Create A Matrix
Slug: create_a_matrix
Summary: How to create a matrix in Python.
Date: 2017-09-03 12:00
Category: Machine Learning
Tags: Vectors Matrices Arrays
Authors: Chris Albon

Preliminaries


In [1]:
# Load library
import numpy as np

Create Matrix


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

Note NumPy's mat data structure is less flexible for our purposes and should be avoided.