blob: 80dcf8491185634d2d9fd6379a3954c141b8f691 [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.13"/>
<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: bayes.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="navtreedata.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/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { init_search(); });
</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 type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<!-- hack in the navigation tree -->
<script type="text/javascript" src="eigen_navtree_hacks.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', 'madlib.apache.org');
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 id="projectlogo"><a href="http://madlib.apache.org"><img alt="Logo" src="madlib.png" height="50" style="padding-left:0.5em;" border="0"/ ></a></td>
<td style="padding-left: 0.5em;">
<div id="projectname">
<span id="projectnumber">1.19.0</span>
</div>
<div id="projectbrief">User Documentation for Apache MADlib</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.13 -->
<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('bayes_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)">
</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">bayes.sql_in File Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>SQL functions for naive Bayes.
<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:a0671e6ac35a1967f41d2efb9e8417e1b"><td class="memItemLeft" align="right" valign="top">args_and_value_double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#a0671e6ac35a1967f41d2efb9e8417e1b">argmax_transition</a> (args_and_value_double oldmax, integer newkey, float8 newvalue)</td></tr>
<tr class="separator:a0671e6ac35a1967f41d2efb9e8417e1b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab150442ec577f4a0a3948176baf5ebd0"><td class="memItemLeft" align="right" valign="top">args_and_value_double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#ab150442ec577f4a0a3948176baf5ebd0">argmax_combine</a> (args_and_value_double max1, args_and_value_double max2)</td></tr>
<tr class="separator:ab150442ec577f4a0a3948176baf5ebd0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa7017323fd6fad40c9acbbee5f1fec7e"><td class="memItemLeft" align="right" valign="top">integer []&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#aa7017323fd6fad40c9acbbee5f1fec7e">argmax_final</a> (args_and_value_double finalstate)</td></tr>
<tr class="separator:aa7017323fd6fad40c9acbbee5f1fec7e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad47c68a2b8aeedf66d509f0c32a9732d"><td class="memItemLeft" align="right" valign="top">aggregate integer []&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#ad47c68a2b8aeedf66d509f0c32a9732d">argmax</a> (integer key, float8 value)</td></tr>
<tr class="separator:ad47c68a2b8aeedf66d509f0c32a9732d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeb4eae7843dd789cc38d5fc57f4ccfb2"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#aeb4eae7843dd789cc38d5fc57f4ccfb2">create_nb_prepared_data_tables</a> (varchar trainingSource, varchar trainingClassColumn, varchar trainingAttrColumn, integer numAttrs, varchar featureProbsDestName, varchar classPriorsDestName)</td></tr>
<tr class="memdesc:aeb4eae7843dd789cc38d5fc57f4ccfb2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Precompute all class priors and feature probabilities. <a href="#aeb4eae7843dd789cc38d5fc57f4ccfb2">More...</a><br /></td></tr>
<tr class="separator:aeb4eae7843dd789cc38d5fc57f4ccfb2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3ed5ddbc4cab1013db8604be58a6da3d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#a3ed5ddbc4cab1013db8604be58a6da3d">create_nb_prepared_data_tables</a> (varchar trainingSource, varchar trainingClassColumn, varchar trainingAttrColumn, varchar numericAttrsColumnIndices, integer numAttrs, varchar featureProbsDestName, varchar numericFeatureStatsDestName, varchar classPriorsDestName)</td></tr>
<tr class="separator:a3ed5ddbc4cab1013db8604be58a6da3d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a798402280fc6db710957ae3ab58767e0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#a798402280fc6db710957ae3ab58767e0">create_nb_classify_view</a> (varchar featureProbsSource, varchar classPriorsSource, varchar classifySource, varchar classifyKeyColumn, varchar classifyAttrColumn, integer numAttrs, varchar destName)</td></tr>
<tr class="memdesc:a798402280fc6db710957ae3ab58767e0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a view with columns <code>(key, nb_classification)</code> <a href="#a798402280fc6db710957ae3ab58767e0">More...</a><br /></td></tr>
<tr class="separator:a798402280fc6db710957ae3ab58767e0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4e8e24120269be2b58f959ab5473b2cb"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#a4e8e24120269be2b58f959ab5473b2cb">create_nb_classify_view</a> (varchar featureProbsSource, varchar classPriorsSource, varchar classifySource, varchar classifyKeyColumn, varchar classifyAttrColumn, integer numAttrs, varchar numericFeatureStatsSource, varchar destName)</td></tr>
<tr class="separator:a4e8e24120269be2b58f959ab5473b2cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6472f620099368cb8c334e0badb12133"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#a6472f620099368cb8c334e0badb12133">create_nb_classify_view</a> (varchar trainingSource, varchar trainingClassColumn, varchar trainingAttrColumn, varchar classifySource, varchar classifyKeyColumn, varchar classifyAttrColumn, integer numAttrs, varchar destName)</td></tr>
<tr class="separator:a6472f620099368cb8c334e0badb12133"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a76a03f1d7ff2b1891cb310668077b386"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#a76a03f1d7ff2b1891cb310668077b386">create_nb_classify_view</a> (varchar trainingSource, varchar trainingClassColumn, varchar trainingAttrColumn, varchar numericAttrsColumnIndices, varchar classifySource, varchar classifyKeyColumn, varchar classifyAttrColumn, integer numAttrs, varchar destName)</td></tr>
<tr class="separator:a76a03f1d7ff2b1891cb310668077b386"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a163afffd0c845d325f060f74bcf02243"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#a163afffd0c845d325f060f74bcf02243">create_nb_probs_view</a> (varchar featureProbsSource, varchar classPriorsSource, varchar classifySource, varchar classifyKeyColumn, varchar classifyAttrColumn, integer numAttrs, varchar destName)</td></tr>
<tr class="memdesc:a163afffd0c845d325f060f74bcf02243"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create view with columns <code>(key, class, nb_prob)</code> <a href="#a163afffd0c845d325f060f74bcf02243">More...</a><br /></td></tr>
<tr class="separator:a163afffd0c845d325f060f74bcf02243"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2e02b0ebb0b4c2ca77b1748662bae78f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#a2e02b0ebb0b4c2ca77b1748662bae78f">create_nb_probs_view</a> (varchar featureProbsSource, varchar classPriorsSource, varchar classifySource, varchar classifyKeyColumn, varchar classifyAttrColumn, integer numAttrs, varchar numericFeatureStatsSource, varchar destName)</td></tr>
<tr class="separator:a2e02b0ebb0b4c2ca77b1748662bae78f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aba5d695641530e55b25c8007b77142b9"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#aba5d695641530e55b25c8007b77142b9">create_nb_probs_view</a> (varchar trainingSource, varchar trainingClassColumn, varchar trainingAttrColumn, varchar classifySource, varchar classifyKeyColumn, varchar classifyAttrColumn, integer numAttrs, varchar destName)</td></tr>
<tr class="separator:aba5d695641530e55b25c8007b77142b9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6d1186aa04f4d4e3ac44035467818d3c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="bayes_8sql__in.html#a6d1186aa04f4d4e3ac44035467818d3c">create_nb_probs_view</a> (varchar trainingSource, varchar trainingClassColumn, varchar trainingAttrColumn, varchar numericAttrsColumnIndices, varchar classifySource, varchar classifyKeyColumn, varchar classifyAttrColumn, integer numAttrs, varchar destName)</td></tr>
<tr class="separator:a6d1186aa04f4d4e3ac44035467818d3c"><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 Naive Bayes Classification, see the module description <a class="el" href="group__grp__bayes.html">Naive Bayes Classification</a>. </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="ad47c68a2b8aeedf66d509f0c32a9732d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad47c68a2b8aeedf66d509f0c32a9732d">&#9670;&nbsp;</a></span>argmax()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">aggregate integer [] argmax </td>
<td>(</td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>key</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">float8&#160;</td>
<td class="paramname"><em>value</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="ab150442ec577f4a0a3948176baf5ebd0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab150442ec577f4a0a3948176baf5ebd0">&#9670;&nbsp;</a></span>argmax_combine()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">args_and_value_double argmax_combine </td>
<td>(</td>
<td class="paramtype">args_and_value_double&#160;</td>
<td class="paramname"><em>max1</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">args_and_value_double&#160;</td>
<td class="paramname"><em>max2</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="aa7017323fd6fad40c9acbbee5f1fec7e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa7017323fd6fad40c9acbbee5f1fec7e">&#9670;&nbsp;</a></span>argmax_final()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">integer [] argmax_final </td>
<td>(</td>
<td class="paramtype">args_and_value_double&#160;</td>
<td class="paramname"><em>finalstate</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="a0671e6ac35a1967f41d2efb9e8417e1b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0671e6ac35a1967f41d2efb9e8417e1b">&#9670;&nbsp;</a></span>argmax_transition()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">args_and_value_double argmax_transition </td>
<td>(</td>
<td class="paramtype">args_and_value_double&#160;</td>
<td class="paramname"><em>oldmax</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>newkey</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">float8&#160;</td>
<td class="paramname"><em>newvalue</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="a798402280fc6db710957ae3ab58767e0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a798402280fc6db710957ae3ab58767e0">&#9670;&nbsp;</a></span>create_nb_classify_view() <span class="overload">[1/4]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void create_nb_classify_view </td>
<td>(</td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>featureProbsSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classPriorsSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifySource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyKeyColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>numAttrs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>destName</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>The created relation will be</p>
<p><code>{TABLE|VIEW} <em>destName</em> (key, nb_classification)</code></p>
<p>where <code>nb_classification</code> is an array containing the most likely class(es) of the record in <em>classifySource</em> identified by <code>key</code>.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">featureProbsSource</td><td>Name of table with precomputed feature probabilities, as created with <a class="el" href="bayes_8sql__in.html#aeb4eae7843dd789cc38d5fc57f4ccfb2" title="Precompute all class priors and feature probabilities. ">create_nb_prepared_data_tables()</a> </td></tr>
<tr><td class="paramname">classPriorsSource</td><td>Name of table with precomputed class priors, as created with <a class="el" href="bayes_8sql__in.html#aeb4eae7843dd789cc38d5fc57f4ccfb2" title="Precompute all class priors and feature probabilities. ">create_nb_prepared_data_tables()</a> </td></tr>
<tr><td class="paramname">classifySource</td><td>Name of the relation that contains data to be classified </td></tr>
<tr><td class="paramname">classifyKeyColumn</td><td>Name of column in <em>classifySource</em> that can serve as unique identifier (the key of the source relation) </td></tr>
<tr><td class="paramname">classifyAttrColumn</td><td>Name of attributes-array column in <em>classifySource</em> </td></tr>
<tr><td class="paramname">numAttrs</td><td>Number of attributes to use for classification </td></tr>
<tr><td class="paramname">destName</td><td>Name of the view to create</td></tr>
</table>
</dd>
</dl>
<dl class="section note"><dt>Note</dt><dd><code>create_nb_classify_view</code> can be called in an ad-hoc fashion. See <a class="el" href="group__grp__bayes.html">Naive Bayes Classification</a> for instructions.</dd></dl>
<dl class="section user"><dt>Usage</dt><dd><ol type="1">
<li>Create Naive Bayes classifications view: <pre>SELECT <a class="el" href="bayes_8sql__in.html#a76a03f1d7ff2b1891cb310668077b386">create_nb_classify_view</a>(
'<em>featureProbsName</em>', '<em>classPriorsName</em>',
'<em>classifySource</em>', '<em>classifyKeyColumn</em>', '<em>classifyAttrColumn</em>',
<em>numAttrs</em>, '<em>destName</em>'
);</pre></li>
<li>Show Naive Bayes classifications: <pre>SELECT * FROM <em>destName</em>;</pre> </li>
</ol>
</dd></dl>
</div>
</div>
<a id="a4e8e24120269be2b58f959ab5473b2cb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4e8e24120269be2b58f959ab5473b2cb">&#9670;&nbsp;</a></span>create_nb_classify_view() <span class="overload">[2/4]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void create_nb_classify_view </td>
<td>(</td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>featureProbsSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classPriorsSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifySource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyKeyColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>numAttrs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>numericFeatureStatsSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>destName</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="a6472f620099368cb8c334e0badb12133"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6472f620099368cb8c334e0badb12133">&#9670;&nbsp;</a></span>create_nb_classify_view() <span class="overload">[3/4]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void create_nb_classify_view </td>
<td>(</td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingClassColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifySource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyKeyColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>numAttrs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>destName</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="a76a03f1d7ff2b1891cb310668077b386"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a76a03f1d7ff2b1891cb310668077b386">&#9670;&nbsp;</a></span>create_nb_classify_view() <span class="overload">[4/4]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void create_nb_classify_view </td>
<td>(</td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingClassColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>numericAttrsColumnIndices</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifySource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyKeyColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>numAttrs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>destName</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="aeb4eae7843dd789cc38d5fc57f4ccfb2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aeb4eae7843dd789cc38d5fc57f4ccfb2">&#9670;&nbsp;</a></span>create_nb_prepared_data_tables() <span class="overload">[1/2]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void create_nb_prepared_data_tables </td>
<td>(</td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingClassColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>numAttrs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>featureProbsDestName</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classPriorsDestName</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Feature probabilities are stored in a table of format </p><pre>TABLE <em>featureProbsDestName</em> (
class INTEGER,
attr INTEGER,
value INTEGER,
cnt INTEGER,
attr_cnt INTEGER
)</pre><p>Class priors are stored in a table of format </p><pre>TABLE <em>classPriorsDestName</em> (
class INTEGER,
class_cnt INTEGER,
all_cnt INTEGER
)</pre><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">trainingSource</td><td>Name of relation containing the training data </td></tr>
<tr><td class="paramname">trainingClassColumn</td><td>Name of class column in training data </td></tr>
<tr><td class="paramname">trainingAttrColumn</td><td>Name of attributes-array column in training data </td></tr>
<tr><td class="paramname">numAttrs</td><td>Number of attributes to use for classification </td></tr>
<tr><td class="paramname">featureProbsDestName</td><td>Name of feature-probabilities table to create </td></tr>
<tr><td class="paramname">classPriorsDestName</td><td>Name of class-priors table to create</td></tr>
</table>
</dd>
</dl>
<dl class="section user"><dt>Usage</dt><dd>Precompute feature probabilities and class priors: <pre>SELECT <a class="el" href="bayes_8sql__in.html#a3ed5ddbc4cab1013db8604be58a6da3d">create_nb_prepared_data_tables</a>(
'<em>trainingSource</em>', '<em>trainingClassColumn</em>', '<em>trainingAttrColumn</em>',
<em>numAttrs</em>, '<em>featureProbsName</em>', '<em>classPriorsName</em>'
);</pre> </dd></dl>
</div>
</div>
<a id="a3ed5ddbc4cab1013db8604be58a6da3d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3ed5ddbc4cab1013db8604be58a6da3d">&#9670;&nbsp;</a></span>create_nb_prepared_data_tables() <span class="overload">[2/2]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void create_nb_prepared_data_tables </td>
<td>(</td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingClassColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>numericAttrsColumnIndices</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>numAttrs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>featureProbsDestName</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>numericFeatureStatsDestName</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classPriorsDestName</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="a163afffd0c845d325f060f74bcf02243"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a163afffd0c845d325f060f74bcf02243">&#9670;&nbsp;</a></span>create_nb_probs_view() <span class="overload">[1/4]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void create_nb_probs_view </td>
<td>(</td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>featureProbsSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classPriorsSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifySource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyKeyColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>numAttrs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>destName</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>The created view will be of the following form:</p>
<pre>VIEW <em>destName</em> (
key ANYTYPE,
class INTEGER,
nb_prob FLOAT8
)</pre><p>where <code>nb_prob</code> is the Naive-Bayes probability that <code>class</code> is the true class of the record in <em>classifySource</em> identified by <code>key</code>.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">featureProbsSource</td><td>Name of table with precomputed feature probabilities, as created with <a class="el" href="bayes_8sql__in.html#aeb4eae7843dd789cc38d5fc57f4ccfb2" title="Precompute all class priors and feature probabilities. ">create_nb_prepared_data_tables()</a> </td></tr>
<tr><td class="paramname">classPriorsSource</td><td>Name of table with precomputed class priors, as created with <a class="el" href="bayes_8sql__in.html#aeb4eae7843dd789cc38d5fc57f4ccfb2" title="Precompute all class priors and feature probabilities. ">create_nb_prepared_data_tables()</a> </td></tr>
<tr><td class="paramname">classifySource</td><td>Name of the relation that contains data to be classified </td></tr>
<tr><td class="paramname">classifyKeyColumn</td><td>Name of column in <em>classifySource</em> that can serve as unique identifier (the key of the source relation) </td></tr>
<tr><td class="paramname">classifyAttrColumn</td><td>Name of attributes-array column in <em>classifySource</em> </td></tr>
<tr><td class="paramname">numAttrs</td><td>Number of attributes to use for classification </td></tr>
<tr><td class="paramname">destName</td><td>Name of the view to create</td></tr>
</table>
</dd>
</dl>
<dl class="section note"><dt>Note</dt><dd><code>create_nb_probs_view</code> can be called in an ad-hoc fashion. See <a class="el" href="group__grp__bayes.html">Naive Bayes Classification</a> for instructions.</dd></dl>
<dl class="section user"><dt>Usage</dt><dd><ol type="1">
<li>Create Naive Bayes probabilities view: <pre>SELECT <a class="el" href="bayes_8sql__in.html#a6d1186aa04f4d4e3ac44035467818d3c">create_nb_probs_view</a>(
'<em>featureProbsName</em>', '<em>classPriorsName</em>',
'<em>classifySource</em>', '<em>classifyKeyColumn</em>', '<em>classifyAttrColumn</em>',
<em>numAttrs</em>, '<em>destName</em>'
);</pre></li>
<li>Show Naive Bayes probabilities: <pre>SELECT * FROM <em>destName</em>;</pre> </li>
</ol>
</dd></dl>
</div>
</div>
<a id="a2e02b0ebb0b4c2ca77b1748662bae78f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2e02b0ebb0b4c2ca77b1748662bae78f">&#9670;&nbsp;</a></span>create_nb_probs_view() <span class="overload">[2/4]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void create_nb_probs_view </td>
<td>(</td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>featureProbsSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classPriorsSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifySource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyKeyColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>numAttrs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>numericFeatureStatsSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>destName</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="aba5d695641530e55b25c8007b77142b9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aba5d695641530e55b25c8007b77142b9">&#9670;&nbsp;</a></span>create_nb_probs_view() <span class="overload">[3/4]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void create_nb_probs_view </td>
<td>(</td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingClassColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifySource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyKeyColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>numAttrs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>destName</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="a6d1186aa04f4d4e3ac44035467818d3c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6d1186aa04f4d4e3ac44035467818d3c">&#9670;&nbsp;</a></span>create_nb_probs_view() <span class="overload">[4/4]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void create_nb_probs_view </td>
<td>(</td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingSource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingClassColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>trainingAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>numericAttrsColumnIndices</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifySource</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyKeyColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>classifyAttrColumn</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>numAttrs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>destName</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
</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_3ee26ceeadb429f807bd6cd822eca1b9.html">bayes</a></li><li class="navelem"><a class="el" href="bayes_8sql__in.html">bayes.sql_in</a></li>
<li class="footer">Generated on Wed Dec 15 2021 20:27:18 for MADlib by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
</ul>
</div>
</body>
</html>