mirror of
https://github.com/rasbt/python_reference.git
synced 2024-11-23 20:11:13 +00:00
updated readme
This commit is contained in:
parent
99f48330a0
commit
edc17e2907
|
@ -154,11 +154,11 @@
|
|||
|
||||
- [Shell script](./useful_scripts/prepend_python_shebang.sh) For prepending Python-shebangs to .py files.
|
||||
|
||||
- Convert 'tab-delimited' to 'comma-separated' CSV files [[IPython nb](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/useful_scripts/fix_tab_csv.ipynb)]
|
||||
|
||||
- A random string generator [function](./useful_scripts/random_string_generator.py)
|
||||
- A random string generator [function](./useful_scripts/random_string_generator.py).
|
||||
|
||||
- [Converting large CSV files](https://github.com/rasbt/python_reference/blob/master/useful_scripts/large_csv_to_sqlite.py) to SQLite databases using pandas.
|
||||
|
||||
- [Sparsifying a matrix](https://github.com/rasbt/python_reference/blob/master/useful_scripts/sparsify_matrix.py) by zeroing out all elements but the top k elements in a row using NumPy.
|
||||
|
||||
<br>
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
# The matrix could be a distance or similarity matrix (e.g., kernel matrix in kernel PCA),
|
||||
# where we are interested to keep the top k neighbors.
|
||||
|
||||
import numpy as np
|
||||
|
||||
print('Sparsify a matrix by zeroing all elements but the top 2 values in a row.\n')
|
||||
|
||||
A = np.array([[1,2,3,4,5],[9,8,6,4,5],[3,1,7,8,9]])
|
||||
|
|
Loading…
Reference in New Issue
Block a user