Use the np.array.argsort() and list.sort() to get the rank of the number
I have a list and I want to get the rank for each member. This is important for many data mining algorithm, for example kNN (k-Nearest-Neighbor), you want to know the rank of a certain record. For example: myList =…
sort 2d array in python
There are many ways to sort a 2d arrays. In general, you can use the sorted(), np.array.sort(),… But you should also understand what is meaning of list1.sort(list2) ravel() vs. flatten() what return the key function back in sorted() what will…
the crazy * in zip()
I just want to reshape the List without use the numpy, so I found a piece of crazy code in stackoverflow: output: [(‘a’, ‘b’), (‘c’, ‘d’), (‘e’, ‘f’)] After the long consideration, I understand the code at last. The python…
the asterik * in python
Asterik in python is usually very confused for the beginner. Some times it appears one time before a variable like *args, some times it appears two times like **args. Usually it appears in function definition: * and ** allow arbitrary…
normalize vectors
In data mining tasks is the attributes normalizing usually a prerequisite in order to get a meaningful result. For example, if you want to calculate the euclidean distance, the attributes with relative large numerical values will have more influence of…
Solve the path problem in eclipse pydev
If you copy a bundle of python codes into eclipse, usually the pydev can not find the paths. In this case, you have 2 two ways to deal with this problem. right click the folder -> pydev -> Set as…
