First, environmental installation
Environment configuration:
os:red Hat 4.4.7-11
View command: uname-a: Information about the computer and the operating system
Cat/proc/version: Running kernel version
Cat/etc/issue: Release Release information
Installing the NumPy plugin: Yum install NumPy
The installation package information obtained is as follows:
=============================================================================================================== =
Package Arch Version Repository Size
=============================================================================================================== =
Installing:
NumPy x86_64 1.4.1-9.EL6 Base 2.3 M
Installing for dependencies:
Atlas x86_64 3.8.4-2.EL6 Base 2.8 M
Libgfortran x86_64 4.4.7-16.el6 Base 267 k
Python-nose Noarch 0.10.4-3.1.el6 Base K
Python-setuptools Noarch 0.6.10-3.el6 base 336 k
Transaction Summary
=============================================================================================================== =
Install 5 Package (s)
Total Download size:6.0 M
Installed size:24 M
Is this OK [y/n]: Y
Second, numerical operation
1. Calculate the Euclidean distance between two vectors
Vector_one = Array ([0,1,1,0,0,0])
Vector_two = Array ([1,0,0,1,0,0])
Dist = Linalg.norm (vector_one-vector_two) # # #result = 2.0
2. Create a matrix
Martix = Array ([[[1,0,0,0,0,0],[0,1,0,0,0,0],[0,0,1,0,0,0],[0,0,0,1,0,0],[0,0,0,0,1,0],[0,0,0,0,0,1],[1,1,1,1,1,1 ]])
Get the number of rows and columns of the matrix:
Number of rows: martix.shape[0] columns: martix.shape[1]
Numerical computation in Python data mining