NumPy use
1. Using the array to define the matrix
DataSet = Array ([[[1.0,1.1],[1.0,1.0],[0.0,0.0],[0,0.1]])
2. Number of rows (columns) using shape to return a matrix
Dataset.shape[0] #4
DATASET.SHAPE[1] #2
3. Multiply the matrix with tiles
IntX =array ([0,1,1,1])
Tsample = Tile (IntX, (4,2)) # indicates that the matrix row is copied 4 times and the column is copied 2 times
4. Square/Open square of the values of each element of the matrix
Sqdiffmat = diffmat**2
distances = sqdistances**0.5
# Why is (4,2) instead of two parameters? Detailed 6
5. Use Argsort to get the sorted number
x = Array ([3, 1, 2])
Argsort (x) #[1,2,0]
# Argsort can also be ordered in reverse order, can be sequenced by row or sorted by column
6.{}, [], () The difference between the put elements
{} equivalent to the map dictionary
[] equivalent to list array
() is equivalent to a tuple tuple type and cannot be changed after initialization
7.map 2 ways to sort by value
dict= Sorted (Dic.iteritems (), Key=lambda d:d[0])
Sortedclasscount=sorted (Classcount.iteritems (), Key=operator.itemgetter (1), reverse=true)
Getting Started with Python (i) matrix processing