Math for Data Science — Lecture 01 Basic Matrix Operations via Python

In this lecture, we will study Matrix Operations (Initialization, Vector, Multiplication, Transpose, Special Matrix) via Python.

Matrix Definition

Matrix Notation

Matrix Initialization

import numpy as np
print(np.zeros((2,3)))
print(np.random.randint(low = 5,high=12, size=(2, 3)))
A = np.matrix([[1, 2], [3, 4], [5,6]])
print("Type of Matrix A:{}, having {} rows and {} columns".format(type(A),A.shape[0],A.shape[1]))

Vectors

  • Row vector is having 1 row and N columns
  • Column vector is having N rows and 1 column

Matrix Equality

Matrix Multiplication

In below Image 09, matrix multiplication is shown both via python code and hand as well.

  • Matrix multiplication isn’t commutative (AB != BA)

Matrix Transpose

Rules of Matrix Transpose

Special Matrix

Reduce size of Sparse Matrix using CSR (Compressed Sparse Row)

Properties of Determinants

WORK IN PROGRESS !! Jupyter Notebook/.py will be uploaded soon..

Our Next lecture is about using Elementary row operations to find Row Echelon Form (REF), Reduced Row Echelon Form (RREF) and Rank of Matrix (https://medium.com/math-for-data-science/math-for-data-science-lecture-02-elementary-row-operations-via-python-46885a33a84c).

Meanwhile, Please feel free to clap if you liked the article. Also, please subscribe to my YouTube Channel https://www.youtube.com/channel/UC4yh4xPxRP0-bLG_ldnLCHA?sub_confirmation=1

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store