-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataSet.pde
55 lines (50 loc) · 1.3 KB
/
DataSet.pde
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
class DataSet {
int num = 0;
Matrix data;
Matrix labels;
DataSet(int num) {
this.num = num;
data = new Matrix(num, 2);
labels = new Matrix(4, num);
for (int i = 0; i < num; i++) {
int x = (int) random(1, 999);
int y = (int )random(1, 999);
Matrix label = label(x, y);
data.data[i][0] = x;
data.data[i][1] = y;
labels.data[0][i] = label.data[0][0];
labels.data[1][i] = label.data[1][0];
labels.data[2][i] = label.data[2][0];
labels.data[3][i] = label.data[3][0];
}
}
Matrix label(int x, int y) {
Matrix label = new Matrix(4, 1);
if (x <= 500) {
if (y <= 500) {
label.data[0][0] = 1;
label.data[1][0] = 0;
label.data[2][0] = 0;
label.data[3][0] = 0;
} else if (y > 500 && y <= 1000) {
label.data[0][0] = 0;
label.data[1][0] = 0;
label.data[2][0] = 1;
label.data[3][0] = 0;
}
} else if (x > 500 && x <= 1000) {
if (y <= 500) {
label.data[0][0] = 0;
label.data[1][0] = 1;
label.data[2][0] = 0;
label.data[3][0] = 0;
} else if (y > 500 && y <= 1000) {
label.data[0][0] = 0;
label.data[1][0] = 0;
label.data[2][0] = 0;
label.data[3][0] = 1;
}
}
return label;
}
}