| <!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: SVD Matrix Factorisation</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.6</span> <span style="font-size:10pt; font-style:italic"><a href="../latest/./group__grp__svdmf.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__svdmf.html',''); |
| </script> |
| <div id="doc-content"> |
| <div class="header"> |
| <div class="headertitle"> |
| <div class="title">SVD Matrix Factorisation</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 SVD Matrix Factorisation:</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__svdmf.svg" width="403" 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 "partial SVD decomposition" method for representing a sparse matrix using a low-rank approximation. Mathematically, this algorithm seeks to find matrices U and V that, for any given A, minimizes:<br/> |
| </p> |
| <p class="formulaDsp"> |
| \[ ||\boldsymbol A - \boldsymbol UV ||_2 \] |
| </p> |
| <p> subject to \( rank(\boldsymbol UV) \leq k \), where \( ||\cdot||_2 \) denotes the Frobenius norm and \( k \leq rank(\boldsymbol A)\). If A is \( m \times n \), then U will be \( m \times k \) and V will be \( k \times n \).</p> |
| <p>This algorithm is not intended to do the full decomposition, or to be used as part of inverse procedure. It effectively computes the SVD of a low-rank approximation of A (preferably sparse), with the singular values absorbed in U and V. Code is based on the write-up as appears at [1], with some modifications.</p> |
| <dl class="user"><dt><b>Input:</b></dt><dd>The <b>input matrix</b> is expected to be of the following form: <pre>{TABLE|VIEW} <em>input_table</em> ( |
| <em>col_num</em> INTEGER, |
| <em>row_num</em> INTEGER, |
| <em>value</em> FLOAT |
| )</pre></dd></dl> |
| <p>Input is contained in a table where column number and row number for each cell are sequential; that is to say that if the data was written as a matrix, those values would be the actual row and column numbers and not some random identifiers. All rows and columns must be associated with a value. There should not be any missing row, columns or values.</p> |
| <dl class="user"><dt><b>Usage:</b></dt><dd>The SVD function is called as follows: <pre>SELECT <a class="el" href="svdmf_8sql__in.html#a456119a507138326cdfda4f402de196f">svdmf_run</a>( '<em>input_table</em>', '<em>col_name</em>', |
| '<em>row_name</em>', '<em>value</em>', <em>num_features</em>);</pre> The function returns two tables <code>matrix_u</code> and <code>matrix_v</code>, which represent the matrices U and V in table format.</dd></dl> |
| <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 svd_test ( |
| col INT, |
| row INT, |
| val FLOAT |
| ); |
| </pre></div></li> |
| <li>Populate the input table with some data. e.g.: <div class="fragment"><pre class="fragment">sql> INSERT INTO svd_test SELECT (g.a%1000)+1, g.a/1000+1, random() FROM generate_series(1,1000) AS g(a); |
| </pre></div></li> |
| <li>Call <a class="el" href="svdmf_8sql__in.html#a6cff34415cca23aa0a826cc08a6283f5" title="Partial SVD decomposition of a sparse matrix into U and V components.">svdmf_run()</a> stored procedure, e.g.: <div class="fragment"><pre class="fragment">sql> select madlib.svdmf_run( <span class="stringliteral">'svd_test'</span>, <span class="stringliteral">'col'</span>, <span class="stringliteral">'row'</span>, <span class="stringliteral">'val'</span>, 3); |
| </pre></div></li> |
| <li>Sample Output: <div class="fragment"><pre class="fragment">INFO: (<span class="stringliteral">'Started svdmf_run() with parameters:'</span>,) |
| INFO: (<span class="stringliteral">' * input_matrix = madlib_svdsparse_test.test'</span>,) |
| INFO: (<span class="stringliteral">' * col_name = col_num'</span>,) |
| INFO: (<span class="stringliteral">' * row_name = row_num'</span>,) |
| INFO: (<span class="stringliteral">' * value = val'</span>,) |
| INFO: (<span class="stringliteral">' * num_features = 3'</span>,) |
| INFO: (<span class="stringliteral">'Copying the source data into a temporary table...'</span>,) |
| INFO: (<span class="stringliteral">'Estimating feature: 1'</span>,) |
| INFO: (<span class="stringliteral">'...Iteration 1: residual_error = 33345014611.1, step_size = 4.9997500125e-10, min_improvement = 1.0'</span>,) |
| INFO: (<span class="stringliteral">'...Iteration 2: residual_error = 33345014557.6, step_size = 5.49972501375e-10, min_improvement = 1.0'</span>,) |
| INFO: (<span class="stringliteral">'...Iteration 3: residual_error = 33345014054.3, step_size = 6.04969751512e-10, min_improvement = 1.0'</span>,) |
| ... |
| INFO: (<span class="stringliteral">'...Iteration 78: residual_error = 2.02512133868, step_size = 5.78105354457e-10, min_improvement = 1.0'</span>,) |
| INFO: (<span class="stringliteral">'...Iteration 79: residual_error = 0.893810181282, step_size = 6.35915889903e-10, min_improvement = 1.0'</span>,) |
| INFO: (<span class="stringliteral">'...Iteration 80: residual_error = 0.34496773222, step_size = 6.99507478893e-10, min_improvement = 1.0'</span>,) |
| INFO: (<span class="stringliteral">'Swapping residual error matrix...'</span>,) |
| <a class="code" href="svdmf_8sql__in.html#a6cff34415cca23aa0a826cc08a6283f5" title="Partial SVD decomposition of a sparse matrix into U and V components.">svdmf_run</a> |
| -------------------------------------------------------------------------------------------- |
| |
| Finished SVD matrix factorisation <span class="keywordflow">for</span> madlib_svdsparse_test.test (row_num, col_num, val). |
| Results: |
| total error = 0.34496773222 |
| number of estimated features = 1 |
| Output: |
| table : madlib.matrix_u |
| table : madlib.matrix_v |
| Time elapsed: 4 minutes 47.86839 seconds. |
| </pre></div></li> |
| </ol> |
| <dl class="user"><dt><b>Literature:</b></dt><dd></dd></dl> |
| <p>[1] 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> |
| <dl class="see"><dt><b>See also:</b></dt><dd>File <a class="el" href="svdmf_8sql__in.html" title="SQL functions for SVD Matrix Factorization.">svdmf.sql_in</a> documenting the SQL functions. </dd></dl> |
| </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 Tue Apr 2 2013 14:57:03 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> |