Created
December 17, 2017 09:28
-
-
Save gvyshnya/16911ce1411f375524c69f95f7af59b7 to your computer and use it in GitHub Desktop.
The code to test the sparsity of your data input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sparsity_ratio(X): | |
return 1.0 - np.count_nonzero(X) / float(X.shape[0] * X.shape[1]) | |
print("input sparsity ratio:", sparsity_ratio(X)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment