当前位置:网站首页>Numpy notes
Numpy notes
2022-07-04 14:56:00 【Taochengyi 2.0】
List of articles
1、 establish numpy Variable
a = np.array([1,2,3,4,5,6])
print(a.shape,a.dtype)
b = np.array([1,2,3,4,5,6]).astype(np.float32)
print(b.shape,b.dtype)
c = np.array([[1,2],[3,4],[5,6]])
print(c.shape,c.dtype)
The running results are as follows :
2、numpy and list convert
a = [1,2,3,4,5,6]
b = np.array(a)
print(b.shape,b.dtype)
a = [[1,2],[3,4],[5,6]]
b = np.array(a)
print(b.shape,b.dtype)
c = np.array([1,2,3,4,5,6])
print(c.tolist()) # Turn into list
d = np.array([[1,2],[3,4],[5,6]])
print(d.tolist()) # Turn into list
The running results are as follows :
3、 Create whole 0 whole 1 Of numpy object
a = np.zeros([3,4])
print(a)
a = np.ones([3,4])
print(a)
The running results are as follows :
4、 Statistical applications
1、 Sum up
To a numpy Object for direct summation :
Specify data type summation :
If you don't operate on a two-dimensional matrix, you can sum all the elements directly :
The two-dimensional matrix operates in different dimensions ( The two-dimensional matrix is not rigorous , Because he is just numpy object , But we can treat it as a matrix )
The concept of dimension is added here , It can be understood as if axis=0 Just look up , And then it's equal to 1 Just look sideways :
2、 mean value
The effect here is similar to the previous average , The explanation can be seen in the mean part :
3、 Standard deviation
The effect here is similar to the previous average , The explanation can be seen in the mean part :
4、 Mean square error
The effect here is similar to the previous average , The explanation can be seen in the mean part :
In addition to the above part , There's more to it :
- abs: Find the absolute value
- sqrt: take a square root
5、 Data processing
1、 Find data
Directly find out whether a certain data exists , Return the location of the data :
Want to find the number of all matching data :
2、 Data sorting
If it is a direct sort , Just write it directly :
If it is a two-dimensional sort , We need to deal with , Or according to the previous numerical direction and horizontal direction :
If you want to get their ranked position :
3、 Get non repeating elements
Here you can use functions directly :
4、 Take the maximum and minimum
Simple value , Use functions directly :
If it's a two-dimensional matrix , Still refer to the above , It is divided into vertical direction and horizontal direction :
If you want to get the position of the maximum and minimum value :( Here I directly use the two-dimensional , One dimensional is the same )
5、 Interval uniform sampling
This is the same as the ordinary python The operation is basically the same , Is the beginning and end, and then add the step size OK 了 :
6、 Matrix operation
1、 Dimension extension
Next, a one-dimensional matrix is extended to a two-dimensional matrix , As shown below :
2、 Matrix splicing
The same direction dimension can be spliced , The effect is as follows :
Of course, we can also use our previous method of adding dimension parameters to splice :
3、 Matrix replication
Copy as you want :
4、 Four operations of matrix
It's the same as ordinary four arithmetic operations :
6、 The inner product of a matrix
It's the stuff of linear algebra , But it should be expressed by functions :
7、 random number
There are three common random numbers , As shown below :
For multi-dimensional Gaussian random numbers , The meaning of each parameter is as follows :
边栏推荐
- Kubernets Pod 存在 Finalizers 一直处于 Terminating 状态
- 韩国AI团队抄袭震动学界!1个导师带51个学生,还是抄袭惯犯
- Redis publier et s'abonner
- Luo Gu - some interesting questions 2
- Comment configurer un accord
- Guitar Pro 8win10最新版吉他学习 / 打谱 / 创作
- leecode学习笔记-约瑟夫问题
- flutter 报错 No MediaQuery widget ancestor found.
- es6模块化
- IO flow: node flow and processing flow are summarized in detail.
猜你喜欢
LVGL 8.2 text shadow
近一亿美元失窃,Horizon跨链桥被攻击事件分析
Flutter reports an error no mediaquery widget ancestor found
【C语言】指针笔试题
LVGL 8.2 Draw label with gradient color
Classify boost libraries by function
Kubernets pod exists finalizers are always in terminating state
Five minutes of machine learning every day: why do we need to normalize the characteristics of numerical types?
leetcode:6109. Number of people who know the secret [definition of DP]
A keepalived high availability accident made me learn it again
随机推荐
为什么国产手机用户换下一部手机时,都选择了iPhone?
Expose Ali's salary and position level
关于FPGA底层资源的细节问题
Ranking list of databases in July: mongodb and Oracle scores fell the most
如何搭建一支搞垮公司的技术团队?
Implementation of macro instruction of first-order RC low-pass filter in signal processing (easy touch screen)
Chapter 16 string localization and message Dictionary (2)
Docker compose public network deployment redis sentinel mode
浮点数如何与0进行比较?
Stm32f1 and stm32subeide programming example -max7219 drives 8-bit 7-segment nixie tube (based on GPIO)
Free, easy-to-use, powerful lightweight note taking software evaluation: drafts, apple memo, flomo, keep, flowus, agenda, sidenote, workflow
毕业季-个人总结
如何配和弦
微博、虎牙挺进兴趣社区:同行不同路
On the implementation plan of MySQL explain
Flutter reports an error no mediaquery widget ancestor found
Guitar Pro 8win10最新版吉他学习 / 打谱 / 创作
Five minutes of machine learning every day: how to use matrix to represent the sample data of multiple characteristic variables?
Who the final say whether the product is good or not? Sonar puts forward performance indicators for analysis to help you easily judge product performance and performance
内存管理总结