I am trying to teach myself about the NMF models (in the context of recommender systems), and I have come across different suggestions on how to set up such a workflow, but I'm not sure if both are valid options and when.
Note: I'm using sklearn which swaps the classical meaning of
H. I will use below the sklearn notation to match the API calls. So below,
H corresponds to the matrix that holds the basis and has the size of
n_features * k.
Let's assume that the data is always normalized correctly or even has only 0-1 values. I found that people approach the task in two ways:
- Split the dataset in train-val-test, and set the test aside. Take the full train set, train NMF on that, and save matrix H. Then take the validation set, and call the transform method to get
W_testand build predictions by multiplying the two like this:
H_train = nmf_model.components_ W_test = nmf_model.transform(x_test) pred_test = np.matmul(W_test, H_train)
Then one can tune the hyperparameters on the validation set and estimate the final performance on the test set. To evaluate the performance, one can use ROC AUC, precision-recall, f1 etc. and look at how performance changes when masking the known values of validation and test sets.
- Take the full dataset, mask some of the known values, train the NMF model on that, get the predictions for the full dataset, and then evaluate the model's performance by checking the precision/recall/precision@k of the masked values.
It looks to me that option 2 is especially popular, but how would one apply the model to the new data? Would one extend the train set and train the new NMF every time? That sounds inefficient. Or would one generate the predictions for the new data similar to how it's done in option 1? But then one can also do the evaluation like in option 1, and the point of masking training data becomes unclear to me.
On the other hand, option (1) often comes with ROC curves which are probabilistic in nature, and NMF is not a probabilistic model, the individual numbers in the matrix
W*H are not probabilities even when the input matrix is logical, so is that really a valid metrics to look at?