Skip to content

Commit

Permalink
Save result nmf
Browse files Browse the repository at this point in the history
  • Loading branch information
kalidouBA committed Dec 4, 2023
1 parent a7b3254 commit cd96f01
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/NMF_optim.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ nmf_conjugate_gradient <- function(V, k, W = NULL, H = NULL, max_iter = 100) {
# W <- project_to_non_negative(matrix(result$par[1:(nrow(V) * k)], nrow = nrow(V), ncol = k))
# H <- project_to_non_negative(matrix(result$par[(nrow(V) * k + 1):length(result$par)], nrow = k, ncol = ncol(V)))

W <- matrix(result$par[1:(nrow(V) * k)], nrow = nrow(V), ncol = k)
H <- matrix(result$par[(nrow(V) * k + 1):length(result$par)], nrow = k, ncol = ncol(V))

n <- length(V)
squared_diff <- (V - W%*%H)^2
mse <- sum(squared_diff) / n
Expand Down

0 comments on commit cd96f01

Please sign in to comment.