-
Notifications
You must be signed in to change notification settings - Fork 0
/
classperceptron_1_1Perceptron.html
220 lines (215 loc) · 10 KB
/
classperceptron_1_1Perceptron.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Perceptron: perceptron.Perceptron Class 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="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>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</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="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Perceptron
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- 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 id="nav-path" class="navpath">
<ul>
<li class="navelem"><b>perceptron</b></li><li class="navelem"><a class="el" href="classperceptron_1_1Perceptron.html">Perceptron</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="#pub-attribs">Public Attributes</a> |
<a href="classperceptron_1_1Perceptron-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">perceptron.Perceptron Class Reference</div> </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ad70c55e3852d4660d9ed7b143e21fe40"><td class="memItemLeft" align="right" valign="top">def </td><td class="memItemRight" valign="bottom"><a class="el" href="classperceptron_1_1Perceptron.html#ad70c55e3852d4660d9ed7b143e21fe40">__init__</a> (self, alpha, nb_iteration)</td></tr>
<tr class="separator:ad70c55e3852d4660d9ed7b143e21fe40"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a107d38819dbe14c373c477af4d34de29"><td class="memItemLeft" align="right" valign="top">def </td><td class="memItemRight" valign="bottom"><a class="el" href="classperceptron_1_1Perceptron.html#a107d38819dbe14c373c477af4d34de29">train</a> (self, X, y)</td></tr>
<tr class="separator:a107d38819dbe14c373c477af4d34de29"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aa2332c23018f576e408475f7f2c96c81"><td class="memItemLeft" align="right" valign="top">def </td><td class="memItemRight" valign="bottom"><a class="el" href="classperceptron_1_1Perceptron.html#aa2332c23018f576e408475f7f2c96c81">predict</a> (self, X_test)</td></tr>
<tr class="separator:aa2332c23018f576e408475f7f2c96c81"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr class="memitem:a8d434dac54aa1a3c4681d1876694c731"><td class="memItemLeft" align="right" valign="top"><a id="a8d434dac54aa1a3c4681d1876694c731"></a>
 </td><td class="memItemRight" valign="bottom"><b>alpha</b></td></tr>
<tr class="separator:a8d434dac54aa1a3c4681d1876694c731"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a94d1d533fe3a7da7414e0c7811b411e0"><td class="memItemLeft" align="right" valign="top"><a id="a94d1d533fe3a7da7414e0c7811b411e0"></a>
 </td><td class="memItemRight" valign="bottom"><b>nb_iteration</b></td></tr>
<tr class="separator:a94d1d533fe3a7da7414e0c7811b411e0"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a123334ee644e893f25c12d23979aa30b"><td class="memItemLeft" align="right" valign="top"><a id="a123334ee644e893f25c12d23979aa30b"></a>
 </td><td class="memItemRight" valign="bottom"><b>weights</b></td></tr>
<tr class="separator:a123334ee644e893f25c12d23979aa30b"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><pre class="fragment"> Perceptron algorithm class.
The perceptron is a binary classifier of the form y^hat=h(x)=sign(w^tx+b) with b the bias and w a vector of real-valued weights.
__init__() initializes the Initializes the perceptron algorithm with specified learning rate and maximum iterations.
activation() applies the Heaviside activation function to the input.
train() trains the perceptron by updating weights and bias to learn a decision boundary that separates classes.
predict() predicts the class labels for a given input.
</pre> </div><h2 class="groupheader">Constructor & Destructor Documentation</h2>
<a id="ad70c55e3852d4660d9ed7b143e21fe40"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad70c55e3852d4660d9ed7b143e21fe40">◆ </a></span>__init__()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">def perceptron.Perceptron.__init__ </td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"> </td>
<td class="paramname"><em>alpha</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"> </td>
<td class="paramname"><em>nb_iteration</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<pre class="fragment">INPUT :
- alpha (which represents the learning_rate) : a float representing the learning rate for the perceptron algorithm (default is 0.01)
- max_iters : an integer representing the maximum number of iterations for training (default is 100).</pre>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="aa2332c23018f576e408475f7f2c96c81"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa2332c23018f576e408475f7f2c96c81">◆ </a></span>predict()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">def perceptron.Perceptron.predict </td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"> </td>
<td class="paramname"><em>X_test</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<pre class="fragment">INPUT :
- X_test : is a MxD numpy array containing the coordinates of new points whose label has to be predicted
OUTPUT :
- y_hat : is a Mx1 numpy array containing the predicted labels for the X_test points
</pre>
</div>
</div>
<a id="a107d38819dbe14c373c477af4d34de29"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a107d38819dbe14c373c477af4d34de29">◆ </a></span>train()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">def perceptron.Perceptron.train </td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"> </td>
<td class="paramname"><em>X</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"> </td>
<td class="paramname"><em>y</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<pre class="fragment">INPUT :
- X : is a 2D NxD numpy array containing the coordinates of points
- y : is a 1D Nx1 numpy array containing the labels for the corresponding row of X (which should be either -1 or 1)</pre>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>perceptron.py</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>