-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTraining.pde
More file actions
61 lines (54 loc) · 726 Bytes
/
Training.pde
File metadata and controls
61 lines (54 loc) · 726 Bytes
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
float f(float x)
{
//y = mx + b
return -0.3 * x + -0.2;
}
class Point
{
float x;
float y;
float bias = 1;
int label;
Point(float x_, float y_)
{
x = x_;
y = y_;
}
Point()
{
x = random(-1,1);
y = random(-1,1);
float lineY = f(x);
if (y > lineY)
{
label = 1;
}
else
{
label = -1;
}
}
float pixelX()
{
return map(x,-1,1,0, width);
}
float pixelY()
{
return map(y,-1,1,height, 0);
}
void show()
{
stroke(0);
if (label == 1)
{
fill(255);
}
else
{
fill(0);
}
float px = pixelX();
float py = pixelY();
ellipse(px, py, 32, 32);
}
}