Skip to content

Instantly share code, notes, and snippets.

%% The SVD demo with Covariance matrix
clear all;
clc;
% origin_mat = [2 4 6 8; 9 8 0 1]; %First original matrix 2x4
origin_mat = [2 4 6 8; 9 8 0 1; 5 3 -2 -3]; %Second original matrix 3x4
[u1, s1, v1]=svd(origin_mat);
@ffliza
ffliza / pca.py
Created February 13, 2018 13:48
PCA with eigen decomposition, Singular value decomposition and matplotlib.mlab PCA
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
@author: Farhana Ferdousi Liza
"""
from matplotlib.mlab import PCA
import numpy as np