| <!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"/> |
| <meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| <meta name="generator" content="Doxygen 1.8.4"/> |
| <title>MADlib: Low-rank Matrix Factorization</title> |
| <link href="tabs.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="jquery.js"></script> |
| <script type="text/javascript" src="dynsections.js"></script> |
| <link href="navtree.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="resize.js"></script> |
| <script type="text/javascript" src="navtree.js"></script> |
| <script type="text/javascript"> |
| $(document).ready(initResizable); |
| $(window).load(resizeHeight); |
| </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 type="text/x-mathjax-config"> |
| MathJax.Hub.Config({ |
| extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"], |
| jax: ["input/TeX","output/HTML-CSS"], |
| }); |
| </script><script src="../mathjax/MathJax.js"></script> |
| <link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| </head> |
| <body> |
| <div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| <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">1.0</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> |
| <!-- end header part --> |
| <!-- Generated by Doxygen 1.8.4 --> |
| <script type="text/javascript"> |
| var searchBox = new SearchBox("searchBox", "search",false,'Search'); |
| </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> |
| <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><!-- top --> |
| <div id="side-nav" class="ui-resizable side-nav-resizable"> |
| <div id="nav-tree"> |
| <div id="nav-tree-contents"> |
| <div id="nav-sync" class="sync"></div> |
| </div> |
| </div> |
| <div id="splitbar" style="-moz-user-select:none;" |
| class="ui-resizable-handle"> |
| </div> |
| </div> |
| <script type="text/javascript"> |
| $(document).ready(function(){initNavTree('group__grp__lmf.html','');}); |
| </script> |
| <div id="doc-content"> |
| <!-- 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><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Groups</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> |
| |
| <div class="header"> |
| <div class="headertitle"> |
| <div class="title">Low-rank Matrix Factorization<div class="ingroups"><a class="el" href="group__grp__matrix__factorization.html">Matrix Factorization</a></div></div> </div> |
| </div><!--header--> |
| <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="414" 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="section user"><dt>About:</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="section user"><dt>Input:</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="section user"><dt>Usage:</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="section user"><dt>Examples:</dt><dd><ol type="1"> |
| <li>Prepare an input table/view: <div class="fragment"><div class="line">CREATE TABLE lmf_data (</div> |
| <div class="line"> column INT,</div> |
| <div class="line"> row INT,</div> |
| <div class="line"> value FLOAT8</div> |
| <div class="line">);</div> |
| </div><!-- fragment --></li> |
| <li>Populate the input table with some data. e.g.: <div class="fragment"><div class="line">INSERT INTO lmf_data VALUES (1, 1, 5.0);</div> |
| <div class="line">INSERT INTO lmf_data VALUES (3, 100, 1.0);</div> |
| <div class="line">INSERT INTO lmf_data VALUES (999, 10000, 2.0);</div> |
| </div><!-- fragment --></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"><div class="line">SELECT madlib.lmf_igd_run(</div> |
| <div class="line"><span class="stringliteral">'lmf_model'</span>, -- result table</div> |
| <div class="line"><span class="stringliteral">'lmf_data'</span>, -- input table</div> |
| <div class="line"><span class="stringliteral">'row'</span>, <span class="stringliteral">'col'</span>, <span class="stringliteral">'value'</span>, -- table column names</div> |
| <div class="line">999, -- row dimension</div> |
| <div class="line">10000, -- column dimension</div> |
| <div class="line">3, -- rank (number of features)</div> |
| <div class="line">0.1, -- stepsize</div> |
| <div class="line">2, -- initial value scale factor</div> |
| <div class="line">10, -- maximal number of iterations</div> |
| <div class="line">1e-9); -- error tolerance</div> |
| </div><!-- fragment --> Example output (the exact result may not be the same): <div class="fragment"><div class="line">NOTICE:</div> |
| <div class="line">Finished low-rank matrix factorization <span class="keyword">using</span> incremental gradient</div> |
| <div class="line">DETAIL:</div> |
| <div class="line"> table : lmf_data (row, col, value)</div> |
| <div class="line">Results:</div> |
| <div class="line"> RMSE = 4.31144557397543e-05</div> |
| <div class="line">Output:</div> |
| <div class="line"> view : SELECT * FROM lmf_model WHERE <span class="keywordtype">id</span> = 1</div> |
| <div class="line"> <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></div> |
| <div class="line">-------------</div> |
| <div class="line"> 1</div> |
| <div class="line">(1 row)</div> |
| </div><!-- fragment --></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"><div class="line">SELECT array_dims(matrix_u), array_dims(matrix_v) FROM lmf_model WHERE <span class="keywordtype">id</span> = 1;</div> |
| </div><!-- fragment --> Example output: <div class="fragment"><div class="line"> array_dims | array_dims</div> |
| <div class="line">--------------+----------------</div> |
| <div class="line"> [1:999][1:3] | [1:10000][1:3]</div> |
| <div class="line">(1 row)</div> |
| </div><!-- fragment --></li> |
| <li>Query the result value, e.g.: <div class="fragment"><div class="line">SELECT matrix_u[2:2][1:3] AS row_2_features FROM lmf_model WHERE <span class="keywordtype">id</span> = 1;</div> |
| </div><!-- fragment --> Example output (the exact result may not be the same): <div class="fragment"><div class="line"> row_2_features</div> |
| <div class="line">----------------------------------------------------------</div> |
| <div class="line"> {{0.51117920037359,0.169582297094166,0.837417622096837}}</div> |
| <div class="line">(1 row)</div> |
| </div><!-- fragment --></li> |
| </ol> |
| </dd></dl> |
| <dl class="section user"><dt>Literature:</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><!-- contents --> |
| </div><!-- doc-content --> |
| <!-- start footer part --> |
| <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> |
| <ul> |
| <li class="footer">Generated on Tue Sep 10 2013 15:48:04 for MADlib by |
| <a href="http://www.doxygen.org/index.html"> |
| <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.4 </li> |
| </ul> |
| </div> |
| </body> |
| </html> |