| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| <title>MADlib: Low-rank Matrix Factorization</title> |
| |
| <link href="tabs.css" rel="stylesheet" type="text/css"/> |
| <link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| <link href="navtree.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="jquery.js"></script> |
| <script type="text/javascript" src="resize.js"></script> |
| <script type="text/javascript" src="navtree.js"></script> |
| <script type="text/javascript"> |
| $(document).ready(initResizable); |
| </script> |
| <link href="search/search.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="search/search.js"></script> |
| <script type="text/javascript"> |
| $(document).ready(function() { searchBox.OnSelectItem(0); }); |
| </script> |
| <script src="../mathjax/MathJax.js"> |
| MathJax.Hub.Config({ |
| extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"], |
| jax: ["input/TeX","output/HTML-CSS"], |
| }); |
| </script> |
| </head> |
| <body> |
| <div id="top"><!-- do not remove this div! --> |
| |
| |
| <div id="titlearea"> |
| <table cellspacing="0" cellpadding="0"> |
| <tbody> |
| <tr style="height: 56px;"> |
| |
| |
| <td style="padding-left: 0.5em;"> |
| <div id="projectname">MADlib |
|  <span id="projectnumber">0.7</span> <span style="font-size:10pt; font-style:italic"><a href="../latest/./group__grp__lmf.html"> A newer version is available</a></span> |
| </div> |
| <div id="projectbrief">User Documentation</div> |
| </td> |
| |
| |
| |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <!-- Generated by Doxygen 1.7.5.1 --> |
| <script type="text/javascript"> |
| var searchBox = new SearchBox("searchBox", "search",false,'Search'); |
| </script> |
| <script type="text/javascript" src="dynsections.js"></script> |
| <div id="navrow1" class="tabs"> |
| <ul class="tablist"> |
| <li><a href="index.html"><span>Main Page</span></a></li> |
| <li><a href="modules.html"><span>Modules</span></a></li> |
| <li><a href="files.html"><span>Files</span></a></li> |
| <li> |
| <div id="MSearchBox" class="MSearchBoxInactive"> |
| <span class="left"> |
| <img id="MSearchSelect" src="search/mag_sel.png" |
| onmouseover="return searchBox.OnSearchSelectShow()" |
| onmouseout="return searchBox.OnSearchSelectHide()" |
| alt=""/> |
| <input type="text" id="MSearchField" value="Search" accesskey="S" |
| onfocus="searchBox.OnSearchFieldFocus(true)" |
| onblur="searchBox.OnSearchFieldFocus(false)" |
| onkeyup="searchBox.OnSearchFieldChange(event)"/> |
| </span><span class="right"> |
| <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> |
| </span> |
| </div> |
| </li> |
| </ul> |
| </div> |
| </div> |
| <div id="side-nav" class="ui-resizable side-nav-resizable"> |
| <div id="nav-tree"> |
| <div id="nav-tree-contents"> |
| </div> |
| </div> |
| <div id="splitbar" style="-moz-user-select:none;" |
| class="ui-resizable-handle"> |
| </div> |
| </div> |
| <script type="text/javascript"> |
| initNavTree('group__grp__lmf.html',''); |
| </script> |
| <div id="doc-content"> |
| <div class="header"> |
| <div class="headertitle"> |
| <div class="title">Low-rank Matrix Factorization</div> </div> |
| <div class="ingroups"><a class="el" href="group__grp__unsuplearn.html">Unsupervised Learning</a></div></div> |
| <div class="contents"> |
| <div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;"> |
| <img id="dynsection-0-trigger" src="closed.png" alt="+"/> Collaboration diagram for Low-rank Matrix Factorization:</div> |
| <div id="dynsection-0-summary" class="dynsummary" style="display:block;"> |
| </div> |
| <div id="dynsection-0-content" class="dyncontent" style="display:none;"> |
| <center><table><tr><td><div class="center"><iframe scrolling="no" frameborder="0" src="group__grp__lmf.svg" width="435" height="40"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div> |
| </td></tr></table></center> |
| </div> |
| <dl class="user"><dt><b>About:</b></dt><dd></dd></dl> |
| <p>This module implements "factor model" for representing an incomplete matrix using a low-rank approximation [1]. Mathematically, this model seeks to find matrices U and V (also referred as factors) that, for any given incomplete matrix A, minimizes: </p> |
| <p class="formulaDsp"> |
| \[ \|\boldsymbol A - \boldsymbol UV^{T} \|_2 \] |
| </p> |
| <p> subject to \(rank(\boldsymbol UV^{T}) \leq r\), where \(\|\cdot\|_2\) denotes the Frobenius norm. Let \(A\) be a \(m \times n\) matrix, then \(U\) will be \(m \times r\) and \(V\) will be \(n \times r\), in dimension, and \(1 \leq r \ll \min(m, n)\). This model is not intended to do the full decomposition, or to be used as part of inverse procedure. This model has been widely used in recommendation systems (e.g., Netflix [2]) and feature selection (e.g., image processing [3]).</p> |
| <dl class="user"><dt><b>Input:</b></dt><dd></dd></dl> |
| <p>The <b>input matrix</b> is expected to be of the following form: </p> |
| <pre>{TABLE|VIEW} <em>input_table</em> ( |
| <em>row</em> INTEGER, |
| <em>col</em> INTEGER, |
| <em>value</em> DOUBLE PRECISION |
| )</pre><p>Input is contained in a table that describes an incomplete matrix, by having available entries specified as (row, column, value). The input matrix is expected to be based 1, which means row >= 1, and col >= 1. NULL values are not expected.</p> |
| <dl class="user"><dt><b>Usage:</b></dt><dd></dd></dl> |
| <p>Please find descriptions of SQL functions in <a class="el" href="lmf_8sql__in.html" title="SQL functions for low-rank matrix factorization.">lmf.sql_in</a></p> |
| <p>Output factors matrix U and V are in flatten format. </p> |
| <pre>RESULT AS ( |
| matrix_u DOUBLE PRECISION[], |
| matrix_v DOUBLE PRECISION[], |
| rmse DOUBLE PRECISION |
| );</pre><p>Features correspond to row i is <code>matrix_u[i:i][1:r]</code>. Features correspond to column j is <code>matrix_v[j:j][1:r]</code>.</p> |
| <dl class="user"><dt><b>Examples:</b></dt><dd></dd></dl> |
| <ol type="1"> |
| <li>Prepare an input table/view: <div class="fragment"><pre class="fragment">CREATE TABLE lmf_data ( |
| column INT, |
| row INT, |
| value FLOAT8 |
| ); |
| </pre></div></li> |
| <li>Populate the input table with some data. e.g.: <div class="fragment"><pre class="fragment">INSERT INTO lmf_data VALUES (1, 1, 5.0); |
| INSERT INTO lmf_data VALUES (3, 100, 1.0); |
| INSERT INTO lmf_data VALUES (999, 10000, 2.0); |
| </pre></div></li> |
| <li>Call <a class="el" href="lmf_8sql__in.html#ac1acb1f0e1f7008118f21c83546a4602" title="Low-rank matrix factorization of a incomplete matrix into two factors.">lmf_igd_run()</a> stored procedure, e.g.: <div class="fragment"><pre class="fragment">SELECT madlib.lmf_igd_run( |
| <span class="stringliteral">'lmf_model'</span>, -- result table |
| <span class="stringliteral">'lmf_data'</span>, -- input table |
| <span class="stringliteral">'row'</span>, <span class="stringliteral">'col'</span>, <span class="stringliteral">'value'</span>, -- table column names |
| 999, -- row dimension |
| 10000, -- column dimension |
| 3, -- rank (number of features) |
| 0.1, -- stepsize |
| 2, -- initial value scale factor |
| 10, -- maximal number of iterations |
| 1e-9); -- error tolerance |
| </pre></div> Example output (the exact result may not be the same): <div class="fragment"><pre class="fragment">NOTICE: |
| Finished low-rank matrix factorization <span class="keyword">using</span> incremental gradient |
| DETAIL: |
| table : lmf_data (row, col, value) |
| Results: |
| RMSE = 4.31144557397543e-05 |
| Output: |
| view : SELECT * FROM lmf_model WHERE <span class="keywordtype">id</span> = 1 |
| <a class="code" href="lmf_8sql__in.html#ac1acb1f0e1f7008118f21c83546a4602" title="Low-rank matrix factorization of a incomplete matrix into two factors.">lmf_igd_run</a> |
| ------------- |
| 1 |
| (1 row) |
| </pre></div></li> |
| <li>Sanity check of the result. You may need a model id returned and also indicated by the function <a class="el" href="lmf_8sql__in.html#ac1acb1f0e1f7008118f21c83546a4602" title="Low-rank matrix factorization of a incomplete matrix into two factors.">lmf_igd_run()</a>, assuming 1 here, e.g.: <div class="fragment"><pre class="fragment">SELECT array_dims(matrix_u), array_dims(matrix_v) FROM lmf_model WHERE <span class="keywordtype">id</span> = 1; |
| </pre></div> Example output: <div class="fragment"><pre class="fragment"> array_dims | array_dims |
| --------------+---------------- |
| [1:999][1:3] | [1:10000][1:3] |
| (1 row) |
| </pre></div></li> |
| <li>Query the result value, e.g.: <div class="fragment"><pre class="fragment">SELECT matrix_u[2:2][1:3] AS row_2_features FROM lmf_model WHERE <span class="keywordtype">id</span> = 1; |
| </pre></div> Example output (the exact result may not be the same): <div class="fragment"><pre class="fragment"> row_2_features |
| ---------------------------------------------------------- |
| {{0.51117920037359,0.169582297094166,0.837417622096837}} |
| (1 row) |
| </pre></div></li> |
| </ol> |
| <dl class="user"><dt><b>Literature:</b></dt><dd></dd></dl> |
| <p>[1] N. Srebro and T. Jaakkola. “Weighted Low-Rank Approximations.” In: ICML. Ed. by T. Fawcett and N. Mishra. AAAI Press, 2003, pp. 720–727. isbn: 1-57735-189-4.</p> |
| <p>[2] Simon Funk, Netflix Update: Try This at Home, December 11 2006, <a href="http://sifter.org/~simon/journal/20061211.html">http://sifter.org/~simon/journal/20061211.html</a></p> |
| <p>[3] J. Wright, A. Ganesh, S. Rao, Y. Peng, and Y. Ma. “Robust Principal Component Analysis: Exact Recovery of Corrupted Low-Rank Matrices via Convex Optimization.” In: NIPS. Ed. by Y. Bengio, D. Schuurmans, J. D. Lafferty, C. K. I. Williams, and A. Culotta. Curran Associates, Inc., 2009, pp. 2080–2088. isbn: 9781615679119. </p> |
| </div> |
| </div> |
| <div id="nav-path" class="navpath"> |
| <ul> |
| <!-- window showing the filter options --> |
| <div id="MSearchSelectWindow" |
| onmouseover="return searchBox.OnSearchSelectShow()" |
| onmouseout="return searchBox.OnSearchSelectHide()" |
| onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Functions</a></div> |
| |
| <!-- iframe showing the search results (closed by default) --> |
| <div id="MSearchResultsWindow"> |
| <iframe src="javascript:void(0)" frameborder="0" |
| name="MSearchResults" id="MSearchResults"> |
| </iframe> |
| </div> |
| |
| |
| <li class="footer">Generated on Fri May 10 2013 01:37:13 for MADlib by |
| <a href="http://www.doxygen.org/index.html"> |
| <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li> |
| </ul> |
| </div> |
| |
| |
| </body> |
| </html> |