-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathReader.pde
96 lines (84 loc) · 2.2 KB
/
Reader.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
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
class Reader
{
Table table;
Table ru = loadTable("data/uniques.csv");
Table rn = loadTable("data/newusers.csv");
Table rv = loadTable("data/views.csv");
float[] mins = new float[3];
float[] uniquenorm;
float[] newusersnorm;
float[] viewsnorm;
// int[][][] data = new int[100][1462][6];
String[] tags = new String[100];
int tagCounter = 0;
void loadNorms()
{
// get the max of each.
TableRow rurow = ru.getRow(0);
// String[] v = rurow.split(',');
int[] uniquearr = new int[1462];
int rumax = 0;
for (int ii = 0; ii < 1462; ii++) {
int cv = rurow.getInt(ii);
if (rumax < cv) {
rumax = cv;
}
uniquearr[ii] = cv;
}
TableRow rnrow = rn.getRow(0);
// v = rnrow.split(',');
int[] newusersarr = new int[1462];
int rnmax = 0;
for (int ii = 0; ii < 1462; ii++) {
int cv = rnrow.getInt(ii);
if (rnmax < cv) {
rnmax = cv;
}
newusersarr[ii] = cv;
}
TableRow rvrow = rv.getRow(0);
// v = rvrow.split(',');
int[]viewsarr = new int[1462];
int rvmax = 0;
for (int ii = 0; ii < 1462; ii++) {
int cv = rvrow.getInt(ii);
if (rvmax < cv) {
rvmax = cv;
}
viewsarr[ii] = cv;
}
// loop again to get a vector of the factors
uniquenorm = new float[uniquearr.length];
for (int ii = 0; ii < uniquearr.length; ii++) {
uniquenorm[ii] = (float) uniquearr[ii] / rumax;
}
newusersnorm = new float[newusersarr.length];
for (int ii = 0; ii < newusersarr.length; ii++) {
newusersnorm[ii] = (float) newusersarr[ii] / rnmax;
}
viewsnorm = new float[viewsarr.length];
for (int ii = 0; ii < viewsarr.length; ii++) {
viewsnorm[ii] = (float) viewsarr[ii] / rvmax;
}
// use the arrays
// uniquenorm to normalize based on unique active users per day
// newusersnorm to normalize based on new user registrations per day
// viewsnorm to normalize on site views per day
}
Reader(String path)
{
// maxX = 0;
// maxY = 0;
// langs = new ArrayList<Data>();
table = loadTable(path);
tags = table.getStringColumn(0);
loadNorms();
// println(uniquenorm[0]);
// println(newusersnorm[0]);
// println(viewsnorm[0]);
}
Table getTable()
{
return table;
}
}