blob: 76fcff6747eb60a496a611487a65abb99d6cee85 [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: svdmf.sql_in File Reference</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.4.1</span>
</div>
<div id="projectbrief">User Documentation</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('svdmf_8sql__in.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="summary">
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">svdmf.sql_in File Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>SQL functions for SVD Matrix Factorization.
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a6cff34415cca23aa0a826cc08a6283f5"><td class="memItemLeft" align="right" valign="top">text&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="svdmf_8sql__in.html#a6cff34415cca23aa0a826cc08a6283f5">svdmf_run</a> (text input_table, text col_name, text row_name, text value, int num_features)</td></tr>
<tr class="memdesc:a6cff34415cca23aa0a826cc08a6283f5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Partial SVD decomposition of a sparse matrix into U and V components. <a href="#a6cff34415cca23aa0a826cc08a6283f5">More...</a><br/></td></tr>
<tr class="separator:a6cff34415cca23aa0a826cc08a6283f5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a456119a507138326cdfda4f402de196f"><td class="memItemLeft" align="right" valign="top">text&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="svdmf_8sql__in.html#a456119a507138326cdfda4f402de196f">svdmf_run</a> (text input_table, text col_name, text row_name, text value, int num_features, int num_iterations, float min_error)</td></tr>
<tr class="memdesc:a456119a507138326cdfda4f402de196f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Partial SVD decomposition of a sparse matrix into U and V components. <a href="#a456119a507138326cdfda4f402de196f">More...</a><br/></td></tr>
<tr class="separator:a456119a507138326cdfda4f402de196f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><dl class="section date"><dt>Date</dt><dd>January 2011</dd></dl>
<dl class="section see"><dt>See Also</dt><dd>For a brief introduction to <a class="el" href="svd_8sql__in.html#a9ccd79db12f3a1640003c94aa01d6540">SVD</a> Matrix Factorization, see the module description grp_svdmf. </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a6cff34415cca23aa0a826cc08a6283f5"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">text svdmf_run </td>
<td>(</td>
<td class="paramtype">text&#160;</td>
<td class="paramname"><em>input_table</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">text&#160;</td>
<td class="paramname"><em>col_name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">text&#160;</td>
<td class="paramname"><em>row_name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">text&#160;</td>
<td class="paramname"><em>value</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>num_features</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section warning"><dt>Warning</dt><dd><em> This is an old implementation of Singular Value Decomposition and has been deprecated. For the latest version of SVD, please see <a class="el" href="group__grp__svd.html">Singular Value Decomposition</a></em></dd></dl>
<div class="toc"><b>Contents</b> </p>
<ul>
<li>
<a href="#syntax">SVD Function Syntax</a> </li>
<li>
<a href="#xamples">Examples</a> </li>
<li>
<a href="#literature">Literature Related Topics</a> </li>
</ul>
</div><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">Singular Value Decomposition</a></em></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>
<p><a class="anchor" id="syntax"></a></p>
<dl class="section user"><dt>Function Syntax</dt><dd></dd></dl>
<p>The SVD function is called as follows: </p>
<pre class="syntax">
svdmf_run( input_table,
col_name,
row_name,
value, num_features)
</pre><p>The <b>input matrix</b> is expected to be of the following form: </p>
<pre>{TABLE|VIEW} <em>input_table</em> (
<em>col_num</em> INTEGER,
<em>row_num</em> INTEGER,
<em>value</em> FLOAT
)</pre><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>
<p>The function returns two tables <code>matrix_u</code> and <code>matrix_v</code>, which represent the matrices U and V in table format.</p>
<p><a class="anchor" id="examples"></a></p>
<dl class="section user"><dt>Examples</dt><dd><ol type="1">
<li>Prepare an input table/view. <pre class="example">
CREATE TABLE svd_test ( col INT,
row INT,
val FLOAT
);
</pre></li>
<li>Populate the input table with some data. <pre class="example">
INSERT INTO svd_test SELECT ( g.a%1000)+1, g.a/1000+1, random()
FROM generate_series(1,1000) AS g(a);
</pre></li>
<li><p class="startli">Call the <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. </p>
<pre class="example">
SELECT madlib.svdmf_run( 'svd_test',
'col',
'row',
'val',
3);
</pre><p> Example result: </p>
<pre class="result">
INFO: ('Started <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> with parameters:',)
INFO: (' * input_matrix = madlib_svdsparse_test.test',)
INFO: (' * col_name = col_num',)
INFO: (' * row_name = row_num',)
INFO: (' * value = val',)
INFO: (' * num_features = 3',)
INFO: ('Copying the source data into a temporary table...',)
INFO: ('Estimating feature: 1',)
INFO: ('...Iteration 1: residual_error = 33345014611.1, step_size = 4.9997500125e-10, min_improvement = 1.0',)
INFO: ('...Iteration 2: residual_error = 33345014557.6, step_size = 5.49972501375e-10, min_improvement = 1.0',)
INFO: ('...Iteration 3: residual_error = 33345014054.3, step_size = 6.04969751512e-10, min_improvement = 1.0',)
...
INFO: ('...Iteration 78: residual_error = 2.02512133868, step_size = 5.78105354457e-10, min_improvement = 1.0',)
INFO: ('...Iteration 79: residual_error = 0.893810181282, step_size = 6.35915889903e-10, min_improvement = 1.0',)
INFO: ('...Iteration 80: residual_error = 0.34496773222, step_size = 6.99507478893e-10, min_improvement = 1.0',)
INFO: ('Swapping residual error matrix...',)
svdmf_run
&#160;-------------------------------------------------------------------------------------------</pre><pre class="result"> Finished SVD matrix factorisation for 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></li>
</ol>
</dd></dl>
<p><a class="anchor" id="literature"></a></p>
<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>
<p><a class="anchor" id="related"></a></p>
<dl class="section user"><dt>Related Topics</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. This function takes as input the table representation of a sparse matrix and decomposes it into the specified set of most significant features of matrices of U and V matrix.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">input_table</td><td>Name of the table/view with the source data </td></tr>
<tr><td class="paramname">col_name</td><td>Name of the column containing cell column number </td></tr>
<tr><td class="paramname">row_name</td><td>Name of the column containing cell row number </td></tr>
<tr><td class="paramname">value</td><td>Name of the column containing cell value </td></tr>
<tr><td class="paramname">num_features</td><td>Rank of desired approximation </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a456119a507138326cdfda4f402de196f"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">text svdmf_run </td>
<td>(</td>
<td class="paramtype">text&#160;</td>
<td class="paramname"><em>input_table</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">text&#160;</td>
<td class="paramname"><em>col_name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">text&#160;</td>
<td class="paramname"><em>row_name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">text&#160;</td>
<td class="paramname"><em>value</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>num_features</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>num_iterations</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">float&#160;</td>
<td class="paramname"><em>min_error</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>This function takes as input the table representation of a sparse matrix and decomposes it into the specified set of most significant features of matrices of U and V matrix.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">input_table</td><td>Name of the table/view with the source data </td></tr>
<tr><td class="paramname">col_name</td><td>Name of the column containing cell column number </td></tr>
<tr><td class="paramname">row_name</td><td>Name of the column containing cell row number </td></tr>
<tr><td class="paramname">value</td><td>Name of the column containing cell value </td></tr>
<tr><td class="paramname">num_features</td><td>Rank of desired approximation </td></tr>
<tr><td class="paramname">num_iterations</td><td>Maximum number if iterations to perform regardless of convergence </td></tr>
<tr><td class="paramname">min_error</td><td>Acceptable level of error in convergence. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_efbcf68973d247bbf15f9eecae7f24e3.html">ports</a></li><li class="navelem"><a class="el" href="dir_a4a48839224ef8488facbffa8a397967.html">postgres</a></li><li class="navelem"><a class="el" href="dir_dc596537ad427a4d866006d1a3e1fe29.html">modules</a></li><li class="navelem"><a class="el" href="dir_40c4a35ef279220d890883d91e88ed32.html">svd_mf</a></li><li class="navelem"><a class="el" href="svdmf_8sql__in.html">svdmf.sql_in</a></li>
<li class="footer">Generated on Thu Jan 9 2014 20:25:06 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>