Skip to main content

Andrew NG

Model and cost function

  1. Model representation - Linear regression using Training set

m - number of training examples

x's - input variables / features

y's - output variable / "target" variable

(x,y) - one training example

image

2. Cost function

image

Cost function intuition -

image

image

image

image

Octave

  • Singular Value Decomposition (SVD)

Every nxm matrix can be written as a product of three smaller matrices.

image

  • SVD appreas in lots of places
    • Statistics (PCA)
    • Chemical physics
    • Image processing
    • Genomics
    • Robotics
    • Quantum physics (entanglement)
    • Data embeddings / vector embeddings

Gradient Descent for Linear regression with one variable

image

image

Gradient descent intuition

image

Derivative term

image

Alpha

image

image

image

Gradient Descent for Linear Regression

image

image

image

Gradient descent is a convex function (Global minimum)

Also called (Batch gradient descent) becauses look at all training sample.

image

Linear Algebra Review

Matrix - Rectangular array of numbers.

Dimension of matrix : number of rows * number of columns

image

Vector - is a matrix with one column (n*1 matrix)

Uppercase for matrices

Lower case for others variables, vectors, etc.

image

Addition and Scalar Multiplication

Scalar multiplication is 3matrix (nmatrix).

Scalar division is ⅓ * matrix

Matrix Vector Multiplication

image

Calculating hypothesis using matrix-vector multiplication in octave its easy

image

Matrix - Matrix multiplication

image

If we have 3 hypothesis with 4 houses then,

image

Multiplication Properties

  • Multiplication is not commutative ( AB not equal to BA)
  • Multiplication is Associative ( a*(bc) = (ab)*c)
  • Identity matrix (A.I = I.A = A)

Matrix Inverse and Transpose

Matrix Inverse:

  • 0 does not have an inverse.
  • 3 inverse is 3-1
  • Matrix inverse ( A * A-1 = Identity)
  • Matrix that don't have an inverse are singular or degenerate matrix
  • Ex- 0 matrix doesn't have inverse.

Matrix Transpose:

image