To give a little context from the web, see e.g. <a href="http://www.quuxlabs.com/blog/2010/09/matrix-factorization-a-simple-tutorial-and-implementation-in-python/">http://www.quuxlabs.com/blog/2010/09/matrix-factorization-a-simple-tutorial-and-implementation-in-python/</a> where it explains:<div><br></div><div>"</div><div><font size="2"><span style="background-color:rgba(255,255,255,0)">A question might have come to your mind by now: if we find two matrices <img src="http://www.quuxlabs.com/wp-content/latex/ccf/ccf6cb7a07e53d6a5c3e8449ae73d371-ffffff-000000-0.png" alt="\mathbf{P}" title="\mathbf{P}" class="latex" style="margin: 0px; padding: 0px; vertical-align: middle; max-width: 640px;"> and <img src="http://www.quuxlabs.com/wp-content/latex/5e1/5e1ad0579fc06ddcbda6abaa092b7382-ffffff-000000-0.png" alt="\mathbf{Q}" title="\mathbf{Q}" class="latex" style="margin: 0px; padding: 0px; vertical-align: middle; max-width: 640px;"> such that <img src="http://www.quuxlabs.com/wp-content/latex/4e3/4e37888e71add225aafff9e943e66b88-ffffff-000000-0.png" alt="\mathbf{P} \times \mathbf{Q}" title="\mathbf{P} \times \mathbf{Q}" class="latex" style="margin: 0px; padding: 0px; vertical-align: middle; max-width: 640px;"> approximates <img src="http://www.quuxlabs.com/wp-content/latex/e1f/e1fd601dbae82a538d518550acb1af19-ffffff-000000-0.png" alt="\mathbf{R}" title="\mathbf{R}" class="latex" style="margin: 0px; padding: 0px; vertical-align: middle; max-width: 640px;">, isn’t that our predictions of all the unseen ratings will all be zeros? In fact, we are not really trying to come up with <img src="http://www.quuxlabs.com/wp-content/latex/ccf/ccf6cb7a07e53d6a5c3e8449ae73d371-ffffff-000000-0.png" alt="\mathbf{P}" title="\mathbf{P}" class="latex" style="margin: 0px; padding: 0px; vertical-align: middle; max-width: 640px;"> and <img src="http://www.quuxlabs.com/wp-content/latex/5e1/5e1ad0579fc06ddcbda6abaa092b7382-ffffff-000000-0.png" alt="\mathbf{Q}" title="\mathbf{Q}" class="latex" style="margin: 0px; padding: 0px; vertical-align: middle; max-width: 640px;"> such that we can reproduce <img src="http://www.quuxlabs.com/wp-content/latex/e1f/e1fd601dbae82a538d518550acb1af19-ffffff-000000-0.png" alt="\mathbf{R}" title="\mathbf{R}" class="latex" style="margin: 0px; padding: 0px; vertical-align: middle; max-width: 640px;"> exactly. Instead, we will only try to minimise the errors of the observed user-item pairs. </span></font></div><div><font size="2"><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961);">"<br></span></font><br>Raphael </div><div><br>On Sunday, August 28, 2016, Raphael C <<a href="mailto:drraph@gmail.com">drraph@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thank you for the quick reply.  Just to make sure I understand, if X is sparse and n by n with X[0,0] = 1, X_[n-1, n-1]=0 explicitly set (that is only two values are set in X) then this is treated the same for the purposes of the objective function  as the all zeros n by n matrix with X[0,0] set to 1? That is all elements of X that are not specified explicitly are assumed to be 0?<div><br></div><div>It would be really useful if it were possible to have a version of NMF where contributions to the objective function are only counted where the value is explicitly set in X.  This is AFAIK the standard formulation for collaborative filtering. Would there be any interest in doing this? In theory it should be a simple modification of the optimisation code.</div><div><br></div><div>Raphael <br><div><br></div><div><br><br>On Sunday, August 28, 2016, Arthur Mensch <<a href="javascript:_e(%7B%7D,'cvml','arthur.mensch@inria.fr');" target="_blank">arthur.mensch@inria.fr</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Zeros are considered as zeros in the objective function, not as missing values - - i.e. no mask in the loss function. </p>
<div class="gmail_quote">Le 28 août 2016 16:58, "Raphael C" <<a>drraph@gmail.com</a>> a écrit :<br type="attribution"><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">What I meant was, how is the objective function defined when X is sparse?<font color="#888888"><div><br></div></font><div><font color="#888888">Raphael</font><div><br><br>On Sunday, August 28, 2016, Raphael C <<a>drraph@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Reading the docs for <a href="http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.NMF.html" target="_blank">http://scikit-learn.org/st<wbr>able/modules/generated/sklearn<wbr>.decomposition.NMF.html</a> it says<div><br></div><div><div><p style="margin:1.2em 0px 0.1em;line-height:1.5em"><font size="2"><span style="background-color:rgba(255,255,255,0)">The objective function is:</span></font></p><div><div style="background-image:none;background-position:initial initial;background-repeat:initial initial"><pre style="padding:5px 10px;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:4px;border-bottom-left-radius:4px;margin-top:0.1em;margin-bottom:0.5em;line-height:1.2em;word-break:break-all;word-wrap:break-word;border:1px solid rgb(221,221,221);overflow-x:auto;overflow-y:hidden"><font face="Helvetica Neue, Helvetica, Arial, sans-serif" size="3"><span style="white-space:normal;background-color:rgba(255,255,255,0)">0.5 * ||X - WH||_Fro^2
+ alpha * l1_ratio * ||vec(W)||_1
+ alpha * l1_ratio * ||vec(H)||_1
+ 0.5 * alpha * (1 - l1_ratio) * ||W||_Fro^2
+ 0.5 * alpha * (1 - l1_ratio) * ||H||_Fro^2
</span></font></pre></div></div><p style="margin:1.2em 0px 0.1em;line-height:1.5em"><font size="2"><span style="background-color:rgba(255,255,255,0)">Where:</span></font></p><div><div style="background-image:none"><pre style="padding:5px 10px;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:4px;border-bottom-left-radius:4px;margin-top:0.1em;margin-bottom:0.5em;line-height:1.2em;word-break:break-all;word-wrap:break-word;border:1px solid rgb(221,221,221);overflow-x:auto;overflow-y:hidden"><font face="Helvetica Neue, Helvetica, Arial, sans-serif" size="3"><span style="white-space:normal;background-color:rgba(255,255,255,0)">||A||_Fro^2 = \sum_{i,j} A_{ij}^2 (Frobenius norm)
||vec(A)||_1 = \sum_{i,j} abs(A_{ij}) (Elementwise L1 norm)</span></font></pre><pre style="padding:5px 10px;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:4px;border-bottom-left-radius:4px;margin-top:0.1em;margin-bottom:0.5em;line-height:1.2em;word-break:break-all;word-wrap:break-word;border:1px solid rgb(221,221,221);overflow-x:auto;overflow-y:hidden">This seems to suggest that it is optimising over all values in X even if X is sparse.   When using NMF for collaborative filtering we need the objective function to be defined over only the defined elements of X. The remaining elements should effectively be regarded as missing.</pre><pre style="padding:5px 10px;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:4px;border-bottom-left-radius:4px;margin-top:0.1em;margin-bottom:0.5em;line-height:1.2em;word-break:break-all;word-wrap:break-word;border:1px solid rgb(221,221,221);overflow-x:auto;overflow-y:hidden"><br></pre><pre style="padding:5px 10px;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:4px;border-bottom-left-radius:4px;margin-top:0.1em;margin-bottom:0.5em;line-height:1.2em;word-break:break-all;word-wrap:break-word;border:1px solid rgb(221,221,221);overflow-x:auto;overflow-y:hidden">What is the true objective function NMF is using?</pre><pre style="padding:5px 10px;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:4px;border-bottom-left-radius:4px;margin-top:0.1em;margin-bottom:0.5em;line-height:1.2em;word-break:break-all;word-wrap:break-word;border:1px solid rgb(221,221,221);overflow-x:auto;overflow-y:hidden"><br></pre><pre style="padding:5px 10px;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:4px;border-bottom-left-radius:4px;margin-top:0.1em;margin-bottom:0.5em;line-height:1.2em;word-break:break-all;word-wrap:break-word;border:1px solid rgb(221,221,221);overflow-x:auto;overflow-y:hidden">Raphael</pre></div></div></div></div>
</blockquote></div></div>
<br>______________________________<wbr>_________________<br>
scikit-learn mailing list<br>
<a>scikit-learn@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/scikit-learn</a><br>
<br></blockquote></div>
</blockquote></div></div>
</blockquote></div>