blob: ac6a814aac592fa772ee1cac6f369a8cd652f936 [file] [log] [blame]
<!-- HTML header for doxygen 1.8.4-->
<!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"/>
<meta name="keywords" content="madlib,postgres,greenplum,machine learning,data mining,deep learning,ensemble methods,data science,market basket analysis,affinity analysis,pca,lda,regression,elastic net,huber white,proportional hazards,k-means,latent dirichlet allocation,bayes,support vector machines,svm"/>
<title>MADlib: SVD Matrix Factorisation</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" />
<link href="madlib_extra.css" rel="stylesheet" type="text/css"/>
<!-- google analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-45382226-1', 'auto');
ga('send', 'pageview');
</script>
</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
&#160;<span id="projectnumber">1.2</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>
<!--BEGIN VERSIONS LINKS-->
<td style="padding-left: 0.5em;">
<div class="versionlist"><ul>
<li class="head">More versions:</li>
<li><a href="../v1.1/index.html">v1.1</li>
<li><a href="../v1.0/index.html">v1.0</li>
<li><a href="../v0.7/index.html">v0.7</li>
<li><a href="../v0.5/index.html">v0.5</li></ul>
</div>
</td>
<td> <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>
</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><!-- 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__svdmf.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">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</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">SVD Matrix Factorisation<div class="ingroups"><a class="el" href="group__grp__early__stage.html">Early Stage Development</a></div></div> </div>
</div><!--header-->
<div class="contents">
<dl class="section warning"><dt>Warning</dt><dd><em> This is an old implementation of Support Vector Decomposition and has been deprecated. For the latest version of SVD, please see <a class="el" href="group__grp__svd.html">Support Vector Decomposition</a></em></dd></dl>
<dl class="section user"><dt>About</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="section user"><dt>Input</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="section user"><dt>Usage</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="section user"><dt>Examples</dt><dd><ol type="1">
<li>Prepare an input table/view: <div class="fragment"><div class="line">CREATE TABLE svd_test (</div>
<div class="line"> col INT,</div>
<div class="line"> row INT,</div>
<div class="line"> val FLOAT</div>
<div class="line">);</div>
</div><!-- fragment --></li>
<li>Populate the input table with some data. e.g.: <div class="fragment"><div class="line">sql&gt; INSERT INTO svd_test <a class="code" href="robust_8sql__in.html#ac9ebd21770ba37efb90e1ccee36fc103">SELECT</a> (g.a%1000)+1, g.a/1000+1, random() FROM generate_series(1,1000) <a class="code" href="marginal_8sql__in.html#a34237a72d975726db472a1e07569e813">AS</a> g(a);</div>
</div><!-- fragment --></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"><div class="line">sql&gt; select madlib.svdmf_run( <span class="stringliteral">&#39;svd_test&#39;</span>, <span class="stringliteral">&#39;col&#39;</span>, <span class="stringliteral">&#39;row&#39;</span>, <span class="stringliteral">&#39;val&#39;</span>, 3);</div>
</div><!-- fragment --></li>
<li>Sample Output: <div class="fragment"><div class="line">INFO: (<span class="stringliteral">&#39;Started svdmf_run() with parameters:&#39;</span>,)</div>
<div class="line">INFO: (<span class="stringliteral">&#39; * input_matrix = madlib_svdsparse_test.test&#39;</span>,)</div>
<div class="line">INFO: (<span class="stringliteral">&#39; * col_name = col_num&#39;</span>,)</div>
<div class="line">INFO: (<span class="stringliteral">&#39; * row_name = row_num&#39;</span>,)</div>
<div class="line">INFO: (<span class="stringliteral">&#39; * value = val&#39;</span>,)</div>
<div class="line">INFO: (<span class="stringliteral">&#39; * num_features = 3&#39;</span>,)</div>
<div class="line">INFO: (<span class="stringliteral">&#39;Copying the source data into a temporary table...&#39;</span>,)</div>
<div class="line">INFO: (<span class="stringliteral">&#39;Estimating feature: 1&#39;</span>,)</div>
<div class="line">INFO: (<span class="stringliteral">&#39;...Iteration 1: residual_error = 33345014611.1, step_size = 4.9997500125e-10, min_improvement = 1.0&#39;</span>,)</div>
<div class="line">INFO: (<span class="stringliteral">&#39;...Iteration 2: residual_error = 33345014557.6, step_size = 5.49972501375e-10, min_improvement = 1.0&#39;</span>,)</div>
<div class="line">INFO: (<span class="stringliteral">&#39;...Iteration 3: residual_error = 33345014054.3, step_size = 6.04969751512e-10, min_improvement = 1.0&#39;</span>,)</div>
<div class="line">...</div>
<div class="line">INFO: (<span class="stringliteral">&#39;...Iteration 78: residual_error = 2.02512133868, step_size = 5.78105354457e-10, min_improvement = 1.0&#39;</span>,)</div>
<div class="line">INFO: (<span class="stringliteral">&#39;...Iteration 79: residual_error = 0.893810181282, step_size = 6.35915889903e-10, min_improvement = 1.0&#39;</span>,)</div>
<div class="line">INFO: (<span class="stringliteral">&#39;...Iteration 80: residual_error = 0.34496773222, step_size = 6.99507478893e-10, min_improvement = 1.0&#39;</span>,)</div>
<div class="line">INFO: (<span class="stringliteral">&#39;Swapping residual error matrix...&#39;</span>,)</div>
<div class="line"> <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></div>
<div class="line">--------------------------------------------------------------------------------------------</div>
<div class="line"></div>
<div class="line"> Finished <a class="code" href="svd_8sql__in.html#a9ccd79db12f3a1640003c94aa01d6540">SVD</a> matrix factorisation <span class="keywordflow">for</span> madlib_svdsparse_test.test (row_num, col_num, val).</div>
<div class="line"> Results:</div>
<div class="line"> total error = 0.34496773222</div>
<div class="line"> number of estimated features = 1</div>
<div class="line"> <a class="code" href="robust_8sql__in.html#a82fcb1d933c7219a1512a6984f536375">Output</a>:</div>
<div class="line"> table : madlib.matrix_u</div>
<div class="line"> table : madlib.matrix_v</div>
<div class="line"> Time elapsed: 4 minutes 47.86839 seconds.</div>
</div><!-- fragment --></li>
</ol>
</dd></dl>
<dl class="section user"><dt>Literature</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="section see"><dt>See Also</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><!-- 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 Thu Jan 9 2014 20:35:40 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>