没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论

























Numpy Handbook
By Patrick Loeber - Available at python-engineer.com
Learn NumPy with this Handbook! It covers code examples for all essential functions and some
tricks and useful methods. NumPy is the core library for scientific computing in Python. It is
essential for any data science or machine learning algorithms.
Outline
1. NumPy Introduction
2. Installation and Basics
3. Array vs List
4. Dot Product
5. Speed Test Array vs List
6. Multidimensional (nd) Arrays
7. Indexing, Slicing, And Boolean Indexing
8. Reshaping
9. Concatenation
10. Broadcasting
11. Functions and Axis
12. Datatypes
13. Copying
14. Generating Arrays
15. Random Numbers
16. Linear Algebra (Eigenvalues / Solving Linear Systems)
17. Loading CSV Files

1. NumPy Introduction
NumPy is the core library for scientific computing in Python. The central object in the NumPy
library is the NumPy array. The NumPy array is a high-performance multidimensional array
object, which is designed specifically to perform math operations, linear algebra, and probability
calculations. Using a NumPy array is usually a lot faster and needs less code than using a Python
list. A huge part of the NumPy library consists of C code with the Python API serving as a wrapper
around these C functions. This is one of the reasons why NumPy is so fast.
Most of the popular Machine Learning, Deep Learning, and Data Science libraries use NumPy
under the hood:
Scikit-learn
Matplotlib
Pandas
Different use cases and operations that can be achieved easily with NumPy:
Dot product/inner product
Matrix multiplication
Element wise matrix product
Solving linear systems
Inverse
Determinant
Choose random numbers (e.g. Gaussian/Uniform)
Working with images represented as array
... and many more

2. Installation and Array Basics
Installation with pip or Anaconda:
Import numpy:
Central object is the array:
Essential methods:
$ pip install numpy
or
$ conda install numpy
import numpy as np
# check verion
np.__version__
# --> 1.19.1
a = np.array([1,2,3,4,5])
!
a # [1 2 3 4 5]
a.shape # shape of the array: (5,)
a.dtype # type of the elements: int32
a.ndim # number of dimensions: 1
a.size # total number of elements: 5
a.itemsize # the size in bytes of each element: 4
a = np.array([1,2,3])
# access and change elements
print(a[0]) # 1
a[0] = 5
print(a) # [5 2 3]
!
# elementwise math operations
b = a * np.array([2,0,2])
print(b) # [10 0 6]
print(a.sum()) # 10

3. Array vs List
l = [1,2,3]
a = np.array([1,2,3]) # create an array from a list
print(l) # [1, 2, 3]
print(a) # [1 2 3]
!
# adding new item
l.append(4)
#a.append(4) error: size of array is fixed
!
# there are ways to add items, but this essentially creates new arrays
l2 = l + [5]
print(l2) # [1, 2, 3, 4, 5]
!
a2 = a + np.array([4])
print(a2) # this is called broadcasting, adds 4 to each element
# -> [5 6 7]
!
# vector addidion (this is technically correct compared to broadcasting)
a3 = a + np.array([4,4,4])
print(a3) # [5 6 7]
!
#a3 = a + np.array([4,5]) # error, can't add vectors of different sizes
!
# multiplication
l2 = 2 * l # list l repeated 2 times, same a l+l
print(l2)
# -> [1, 2, 3, 4, 1, 2, 3, 4]
!
a3 = 2 * a # multiplication for each element
!
print(a3)
# -> [2 4 6]
!
# modify each item in the list
l2 = []
for i in l:
l2.append(i**2)
print(l2) # [1, 4, 9, 16]
!
# or list comprehension
l2 = [i**2 for i in l]
print(l2) # [1, 4, 9, 16]
!
a2 = a**2 # -> squares each element!
剩余15页未读,继续阅读
资源评论


技术与健康
- 粉丝: 1689
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 在PC棋盘上布局移动互联网联想合资NEC背后有深意.docx
- 山东网络车盟文化广场汽车体育会.ppt
- 史上超全的CAD练习图.doc
- 大数据时代医院信息化档案建设研究.doc
- 高校信息化建设──智慧校园的思考.doc
- 浅析兵团城镇信息化建设中NCB技术的应用.doc
- 机电安装工程项目管理及质量控制分析.docx
- 大数据背景下网络信息安全问题与对策.docx
- 互联网保险的风险与监管-全面剖析.pptx
- 基于PROTEUS的PIC单片机方案设计书——多路抢答器方案设计书.doc
- 员工宿舍网络视频监控系统方案-公共场所其他.docx
- 包装印刷瓦楞纸箱包装CAD软件的研制.doc
- 基于互联网网络条件下网络监控设备的应用方向.docx
- 单片机病房无人看护系统研究报告与设计方案(修)doc.doc
- 单片机课程设计-数字电压表.doc
- 广西壮族自治区百色市推进小煤矿机械化信息化标准化建设经验材料.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
