Include dependency graph for adaline_learning.c:</div>
<divclass="dyncontent">
<divclass="center"><iframescrolling="no"frameborder="0"src="../../d9/dcc/adaline__learning_8c__incl.svg"width="611"height="127"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<trclass="memdesc:"><tdclass="mdescLeft"> </td><tdclass="mdescRight">structure to hold adaline model parameters <ahref="../../d2/daa/structadaline.html#details">More...</a><br/></td></tr>
<trclass="memdesc:ga555ba960994e9bccb2029764588f694f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Maximum number of iterations to learn. <br/></td></tr>
<trclass="memdesc:ga251695a79baa885cafdcf6d8ed4ac120"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Operator to print the weights of the model. <ahref="../../da/d2a/group__adaline.html#ga251695a79baa885cafdcf6d8ed4ac120">More...</a><br/></td></tr>
<trclass="memdesc:gac70b578aee679005fd336073969c3d94"><tdclass="mdescLeft"> </td><tdclass="mdescRight">predict the output of the model for given set of features <ahref="../../da/d2a/group__adaline.html#gac70b578aee679005fd336073969c3d94">More...</a><br/></td></tr>
<trclass="memitem:ga20d3642e0a87f36fdb7bf91b023cd166"><tdclass="memItemLeft"align="right"valign="top">double </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="../../da/d2a/group__adaline.html#ga20d3642e0a87f36fdb7bf91b023cd166">adaline_fit_sample</a> (struct <aclass="el"href="../../d2/daa/structadaline.html">adaline</a> *ada, const double *x, const int y)</td></tr>
<trclass="memdesc:ga20d3642e0a87f36fdb7bf91b023cd166"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Update the weights of the model using supervised learning for one feature vector. <ahref="../../da/d2a/group__adaline.html#ga20d3642e0a87f36fdb7bf91b023cd166">More...</a><br/></td></tr>
<trclass="memitem:gaa52120912e32d2893fe1c6d78da5befd"><tdclass="memItemLeft"align="right"valign="top">void </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="../../da/d2a/group__adaline.html#gaa52120912e32d2893fe1c6d78da5befd">adaline_fit</a> (struct <aclass="el"href="../../d2/daa/structadaline.html">adaline</a> *ada, double **X, const int *y, const int <aclass="el"href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>)</td></tr>
<trclass="memdesc:gaa52120912e32d2893fe1c6d78da5befd"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Update the weights of the model using supervised learning for an array of vectors. <ahref="../../da/d2a/group__adaline.html#gaa52120912e32d2893fe1c6d78da5befd">More...</a><br/></td></tr>
<trclass="memdesc:ab4ecb3accf5d9e0263087e7265bbe3a9"><tdclass="mdescLeft"> </td><tdclass="mdescRight">test function to predict points in a 2D coordinate system above the line \(x=y\) as +1 and others as -1. <ahref="../../dd/d8c/adaline__learning_8c.html#ab4ecb3accf5d9e0263087e7265bbe3a9">More...</a><br/></td></tr>
<trclass="memdesc:a05cc9a0acb524fde727a4d7b4a747ee6"><tdclass="mdescLeft"> </td><tdclass="mdescRight">test function to predict points in a 2D coordinate system above the line \(x+3y=-1\) as +1 and others as -1. <ahref="../../dd/d8c/adaline__learning_8c.html#a05cc9a0acb524fde727a4d7b4a747ee6">More...</a><br/></td></tr>
<trclass="memdesc:a3f37b9f073f7e57fd0b39d70718af1b1"><tdclass="mdescLeft"> </td><tdclass="mdescRight">test function to predict points in a 3D coordinate system lying within the sphere of radius 1 and centre at origin as +1 and others as -1. <ahref="../../dd/d8c/adaline__learning_8c.html#a3f37b9f073f7e57fd0b39d70718af1b1">More...</a><br/></td></tr>
<divclass="textblock"><p><ahref="https://en.wikipedia.org/wiki/ADALINE">Adaptive Linear Neuron (ADALINE)</a> implementation </p>
<p><imgsrc="https://upload.wikimedia.org/wikipedia/commons/b/be/Adaline_flow_chart.gif"alt=""width="200px"class="inline"/><ahref="https://commons.wikimedia.org/wiki/File:Adaline_flow_chart.gif">source</a> ADALINE is one of the first and simplest single layer artificial neural network. The algorithm essentially implements a linear function </p><pclass="formulaDsp">
<p> where \(x_j\) are the input features of a sample, \(w_j\) are the coefficients of the linear function and \(\theta\) is a constant. If we know the \(w_j\), then for any given set of features, \(y\) can be computed. Computing the \(w_j\) is a supervised learning algorithm wherein a set of features and their corresponding outputs are given and weights are computed using stochastic gradient descent method. </p><dlclass="section author"><dt>Author</dt><dd><ahref="https://github.com/kvedala">Krishna Vedala</a></dd></dl>
<divclass="line"><aname="l00229"></a><spanclass="lineno"> 229</span> <spanclass="keyword">const</span><spanclass="keywordtype">int</span><aclass="code"href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a> = 10; <spanclass="comment">// number of sample points</span></div>
<divclass="line"><aname="l00237"></a><spanclass="lineno"> 237</span> <spanclass="keywordflow">for</span> (<spanclass="keywordtype">int</span> i = 0; i <<aclass="code"href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>; i++)</div>
<divclass="line"><aname="l00245"></a><spanclass="lineno"> 245</span> <aclass="code"href="../../da/d2a/group__adaline.html#gaa52120912e32d2893fe1c6d78da5befd">adaline_fit</a>(&ada, X, Y, <aclass="code"href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>);</div>
<divclass="line"><aname="l00246"></a><spanclass="lineno"> 246</span>  printf(<spanclass="stringliteral">"Model after fit: %s\n"</span>, <aclass="code"href="../../da/d2a/group__adaline.html#ga251695a79baa885cafdcf6d8ed4ac120">adaline_get_weights_str</a>(&ada));</div>
<divclass="center"><divclass="zoom"><iframescrolling="no"frameborder="0"src="../../dd/d8c/adaline__learning_8c_ab4ecb3accf5d9e0263087e7265bbe3a9_cgraph.svg"width="100%"height="480"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
<p>test function to predict points in a 2D coordinate system above the line \(x+3y=-1\) as +1 and others as -1. </p>
<p>Note that each point is defined by 2 values or 2 features. The function will create random sample points for training and test purposes. </p><dlclass="params"><dt>Parameters</dt><dd>
<divclass="line"><aname="l00277"></a><spanclass="lineno"> 277</span> <spanclass="keyword">const</span><spanclass="keywordtype">int</span><aclass="code"href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a> = 50; <spanclass="comment">// number of sample points</span></div>
<divclass="line"><aname="l00287"></a><spanclass="lineno"> 287</span> <spanclass="keywordflow">for</span> (<spanclass="keywordtype">int</span> i = 0; i <<aclass="code"href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>; i++)</div>
<divclass="line"><aname="l00299"></a><spanclass="lineno"> 299</span> <aclass="code"href="../../da/d2a/group__adaline.html#gaa52120912e32d2893fe1c6d78da5befd">adaline_fit</a>(&ada, X, Y, <aclass="code"href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>);</div>
<divclass="line"><aname="l00300"></a><spanclass="lineno"> 300</span>  printf(<spanclass="stringliteral">"Model after fit: %s\n"</span>, <aclass="code"href="../../da/d2a/group__adaline.html#ga251695a79baa885cafdcf6d8ed4ac120">adaline_get_weights_str</a>(&ada));</div>
<divclass="line"><aname="l00304"></a><spanclass="lineno"> 304</span> <spanclass="keywordflow">for</span> (<spanclass="keywordtype">int</span> i = 0; i < N_test_cases; i++)</div>
<divclass="line"><aname="l00319"></a><spanclass="lineno"> 319</span> <spanclass="keywordflow">for</span> (<spanclass="keywordtype">int</span> i = 0; i <<aclass="code"href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>; i++) free(X[i]);</div>
<divclass="center"><divclass="zoom"><iframescrolling="no"frameborder="0"src="../../dd/d8c/adaline__learning_8c_a05cc9a0acb524fde727a4d7b4a747ee6_cgraph.svg"width="100%"height="480"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
<p>test function to predict points in a 3D coordinate system lying within the sphere of radius 1 and centre at origin as +1 and others as -1. </p>
<p>Note that each point is defined by 3 values but we use 6 features. The function will create random sample points for training and test purposes. The sphere centred at origin and radius 1 is defined as: \(x^2+y^2+z^2=r^2=1\) and if the \(r^2<1\), point lies within the sphere else, outside.</p>
<divclass="line"><aname="l00340"></a><spanclass="lineno"> 340</span> <spanclass="keyword">const</span><spanclass="keywordtype">int</span><aclass="code"href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a> = 50; <spanclass="comment">// number of sample points</span></div>
<divclass="line"><aname="l00350"></a><spanclass="lineno"> 350</span> <spanclass="keywordflow">for</span> (<spanclass="keywordtype">int</span> i = 0; i <<aclass="code"href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>; i++)</div>
<divclass="line"><aname="l00367"></a><spanclass="lineno"> 367</span> <aclass="code"href="../../da/d2a/group__adaline.html#gaa52120912e32d2893fe1c6d78da5befd">adaline_fit</a>(&ada, X, Y, <aclass="code"href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>);</div>
<divclass="line"><aname="l00368"></a><spanclass="lineno"> 368</span>  printf(<spanclass="stringliteral">"Model after fit: %s\n"</span>, <aclass="code"href="../../da/d2a/group__adaline.html#ga251695a79baa885cafdcf6d8ed4ac120">adaline_get_weights_str</a>(&ada));</div>
<divclass="line"><aname="l00372"></a><spanclass="lineno"> 372</span> <spanclass="keywordflow">for</span> (<spanclass="keywordtype">int</span> i = 0; i < N_test_cases; i++)</div>
<divclass="line"><aname="l00391"></a><spanclass="lineno"> 391</span> <spanclass="keywordflow">for</span> (<spanclass="keywordtype">int</span> i = 0; i <<aclass="code"href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>; i++) free(X[i]);</div>
<divclass="center"><divclass="zoom"><iframescrolling="no"frameborder="0"src="../../dd/d8c/adaline__learning_8c_a3f37b9f073f7e57fd0b39d70718af1b1_cgraph.svg"width="100%"height="480"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
<divclass="ttc"id="agroup__adaline_html_gaa52120912e32d2893fe1c6d78da5befd"><divclass="ttname"><ahref="../../da/d2a/group__adaline.html#gaa52120912e32d2893fe1c6d78da5befd">adaline_fit</a></div><divclass="ttdeci">void adaline_fit(struct adaline *ada, double **X, const int *y, const int N)</div><divclass="ttdoc">Update the weights of the model using supervised learning for an array of vectors.</div><divclass="ttdef"><b>Definition:</b> adaline_learning.c:184</div></div>
<divclass="ttc"id="aproblem__13_2sol1_8c_html_a0240ac851181b84ac374872dc5434ee4"><divclass="ttname"><ahref="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a></div><divclass="ttdeci">#define N</div><divclass="ttdoc">number of digits of the large number</div><divclass="ttdef"><b>Definition:</b> sol1.c:109</div></div>
<divclass="ttc"id="astructadaline_html_a85dbd7cce6195d11ebb388220b96bde2"><divclass="ttname"><ahref="../../d2/daa/structadaline.html#a85dbd7cce6195d11ebb388220b96bde2">adaline::eta</a></div><divclass="ttdeci">double eta</div><divclass="ttdoc">learning rate of the algorithm</div><divclass="ttdef"><b>Definition:</b> adaline_learning.c:45</div></div>
<divclass="ttc"id="agroup__adaline_html_gac70b578aee679005fd336073969c3d94"><divclass="ttname"><ahref="../../da/d2a/group__adaline.html#gac70b578aee679005fd336073969c3d94">adaline_predict</a></div><divclass="ttdeci">int adaline_predict(struct adaline *ada, const double *x, double *out)</div><divclass="ttdoc">predict the output of the model for given set of features</div><divclass="ttdef"><b>Definition:</b> adaline_learning.c:136</div></div>
<divclass="ttc"id="astructadaline_html"><divclass="ttname"><ahref="../../d2/daa/structadaline.html">adaline</a></div><divclass="ttdoc">structure to hold adaline model parameters</div><divclass="ttdef"><b>Definition:</b> adaline_learning.c:44</div></div>
<divclass="ttc"id="agroup__adaline_html_ga251695a79baa885cafdcf6d8ed4ac120"><divclass="ttname"><ahref="../../da/d2a/group__adaline.html#ga251695a79baa885cafdcf6d8ed4ac120">adaline_get_weights_str</a></div><divclass="ttdeci">char * adaline_get_weights_str(const struct adaline *ada)</div><divclass="ttdoc">Operator to print the weights of the model.</div><divclass="ttdef"><b>Definition:</b> adaline_learning.c:112</div></div>
<divclass="ttc"id="agroup__adaline_html_gacd88962c5f6341e43cbc69b4a7d3485b"><divclass="ttname"><ahref="../../da/d2a/group__adaline.html#gacd88962c5f6341e43cbc69b4a7d3485b">new_adaline</a></div><divclass="ttdeci">struct adaline new_adaline(const int num_features, const double eta)</div><divclass="ttdoc">Default constructor.</div><divclass="ttdef"><b>Definition:</b> adaline_learning.c:59</div></div>