奇异值分解(Singular Value Decomposition,SVD ---一种矩阵分解技术):用小得多的数据集来表示原始数据。主要应用于:信息检索、推荐系统。
SVD 将原始数据集矩阵Data分解成三个矩阵:
SVD 的代码实现:
from numpy import *
from numpy import linalg as la
def loadExData():
return[[0, 0, 0, 2, 2],
[0, 0, 0, 3, 3],
[0, 0, 0, 1, 1],
[1, 1, 1, 0, 0],
[2, 2, 2, 0, 0],
[5, 5, 5, 0, 0],
[1, 1, 1, 0, 0]]
def loadExData2():
return[[0, 0, 0, 0, 0