Positional-only and Keyword-only arguments in Python
2021-06-18
Data selection (indexing and slicing) in Pandas MultiIndex DataFrames
2021-06-24
5 mins read

Click on the links to get the high-resolution cheat sheets.

Algebra

Source: http://tutorial.math.lamar.edu/getfile.aspx?file=B,31,N

Linear Algebra

Source: https://minireference.com/static/tutorials/linear_algebra_in_4_pages.pdf

Calculus

Source: http://tutorial.math.lamar.edu/getfile.aspx?file=B,41,N

Probability

Source: http://www.wzchen.com/s/probability_cheatsheet.pdf

Statistics

Source: http://www.mathcentre.ac.uk/resources/uploaded/43799-prob-stats-ff-for-web.pdf

Python

Source: http://datasciencefree.com
Source: https://www.datacamp.com

R

Source: http://datasciencefree.com/

Machine Learning

Azure Machine Learning

Source: https://docs.microsoft.com/en-us/azure/machine-learning/algorithm-cheat-sheet

scikit-learn

Source: https://scikit-learn.org/stable/tutorial/machine_learning_map/index.html
Source: https://www.datacamp.com

Neural Networks

Source: https://www.asimovinstitute.org/neural-network-zoo/
Source: https://www.asimovinstitute.org/author/fjodorvanveen/

PySpark

Source: https://www.datacamp.com
Source: https://www.datacamp.com

Numpy

Source: https://www.datacamp.com
Source: https://intellipaat.com/blog/tutorial/python-tutorial/numpy-cheat-sheet/
Source: http://datasciencefree.com/

SciPy – Linear Algebra built on Numpy

Source: https://www.datacamp.com

Bokeh (Data Visualization)

Source: https://www.datacamp.com

Pandas

Source: https://www.datacamp.com
Source: https://www.datacamp.com

Matplotlib (Data Visualization)

Source: https://www.datacamp.com

Seaborn (Data Visualization)

Source: https://www.datacamp.com

Keras

Source: https://www.datacamp.com

Jupyter Notebook

Source: https://www.datacamp.com

Reference for Linear Algebra Operations in NumPy

The Python numerical computation library called NumPy provides many linear algebra functions that may be useful for a machine learning practitioner. In this tutorial, you will discover the key functions for working with vectors and matrices that you may find useful as a machine learning practitioner.

Overview

  1. Arrays
  2. Vectors
  3. Matrices
  4. Types of Matrices
  5. Matrix Operations
  6. Matrix Factorization
  7. Statistics

1. Arrays

There are many ways to create NumPy arrays.

Array

from numpy import array
A = array([[1,2,3],[1,2,3],[1,2,3]])

Empty

from numpy import empty
A = empty([3,3])

Zeros

from numpy import zeros
A = zeros([3,5])

Ones

from numpy import ones
A = ones([5, 5])

2. Vectors

A vector is a list or column of scalars.

Vector Addition

c = a + b

Vector Subtraction

c = a - b

Vector Multiplication

c = a * b

Vector Division

c = a / b

Vector Dot Product

c = a.dot(b)
c = a @ b

Vector-Scalar Multiplication

c = a * 2.2

Vector Norm

from numpy.linalg import norm
l2 = norm(v)

3. Matrices

A matrix is a two-dimensional array of scalars.

Matrix Addition

C = A + B
1

Matrix Subtraction

C = A - B

Matrix Multiplication (Hadamard Product)

C = A * B

Matrix Division

C = A / B

Matrix-Matrix Multiplication (Dot Product)

C = A.dot(B)
C = A @ B

Matrix-Vector Multiplication (Dot Product)

C = A.dot(b)
C = A @ b

Matrix-Scalar Multiplication

C = A.dot(2.2)
C = A * 2.2

4. Types of Matrices

Different types of matrices are often used as elements in broader calculations.

Triangle Matrix

# lowerfrom numpy import tril
lower = tril(M)
# upperfrom numpy import triu
upper = triu(M)

Diagonal Matrix

from numpy import diag
d = diag(M)

Identity Matrix

from numpy import eye
I = eye(3)

5. Matrix Operations

Matrix operations are often used as elements in broader calculations.

Matrix Transpose

B = A.T

Matrix Inversion

from numpy.linalg import inv
B = inv(A)

Matrix Trace

from numpy import trace
B = trace(A)

Matrix Determinant

from numpy.linalg import det
B = det(A)

Matrix Rank

from numpy.linalg import matrix_rank
r = matrix_rank(A)

6. Matrix Factorization

Matrix factorization, or matrix decomposition, breaks a matrix down into its constituent parts to make other operations simpler and more numerically stable.

LU Decomposition

from scipy.linalg import lu
P, L, U = lu(A)

QR Decomposition

from numpy.linalg import qr
Q, R = qr(A, 'complete')

Eigendecomposition

from numpy.linalg import eig
values, vectors = eig(A)

Singular-Value Decomposition

from scipy.linalg import svd
U, s, V = svd(A)

7. Statistics

Statistics summarize the contents of vectors or matrices and are often used as components in broader operations.

Mean

from numpy import mean
result = mean(v)

Variance

from numpy import var
result = var(v, ddof=1)

Standard Deviation

from numpy import std
result = std(v, ddof=1)

Covariance Matrix

from numpy import cov
sigma = cov(v1, v2)

Linear Least Squares

from numpy.linalg import lstsq
b = lstsq(X, y)

Source:

https://medium.com/analytics-vidhya/data-science-cheat-sheets-109ddcb1aca8

https://machinelearningmastery.com/linear-algebra-cheat-sheet-for-machine-learning/

Amir Masoud Sefidian
Amir Masoud Sefidian
Machine Learning Engineer

Comments are closed.