updated readme

This commit is contained in:
rasbt 2015-02-06 11:58:24 -05:00
parent 99f48330a0
commit edc17e2907
2 changed files with 5 additions and 3 deletions

View File

@ -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>

View File

@ -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]])