Created
September 22, 2023 14:52
-
-
Save idmn/2873016177234b65a7d19c62305964d1 to your computer and use it in GitHub Desktop.
NMF essence
This file contains 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
library(NMF) | |
# random non-negative matrix | |
v <- rmatrix(20, 10) | |
# fit an NMF model | |
x <- nmf(v, 5) | |
# decomposition components | |
x@fit@W | |
x@fit@H | |
# decomposition is not precise | |
dec_v <- x@fit@W %*% x@fit@H | |
hist(abs(v - dec_v)) | |
# predicting clusters | |
predict(x, 'rows') | |
# actually means finding the largest value in each W row | |
apply(x@fit@W, 1, which.max) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment