Merge pull request #7 from jiangzhonglian/master

1. 机器学习基础预习完全
This commit is contained in:
ApacheCN
2017-02-27 12:09:52 +08:00
committed by GitHub
2 changed files with 16 additions and 3 deletions

View File

@@ -22,4 +22,4 @@
* 6.使用算法
* Python相关的库
* 科学函数库SciPy、`NumPy`(底层语言C和Fortran)
* 绘图工具库:`Matplotlib`
* 绘图工具库:`Matplotlib`

View File

@@ -1,7 +1,7 @@
#!/usr/bin/python
# coding:utf8
from numpy import random
from numpy import random, mat, eye
'''
# NumPy 矩阵和数字的区别
@@ -16,6 +16,19 @@ NumPy存在2中不同的数据类型:
'''
# 生成一个 4*4 的随机数组
print random.rand(4, 4)
randArray = random.rand(4, 4)
# 转化关系, 数组转化为矩阵
randMat = mat(randArray)
# .I表示对矩阵求逆
invRandMat = randMat.I
# 输出结果
print randArray, '\n', randMat, '\n', invRandMat
# 矩阵和逆矩阵 进行求积 (单位矩阵对角线都为1嘛理论上4*4的矩阵其他的都为0)
myEye = randMat*invRandMat
# 误差
print myEye - eye(4)
'''
如果上面的代码运行没有问题说明numpy安装没有问题
'''