PerryXDeng 5 years ago
parent
commit
d29c7e5088
11 changed files with 9750 additions and 6 deletions
  1. +355
    -0
      data_preparation/cleaned/fatigue_total_sum.csv
  2. +336
    -0
      data_preparation/cleaned/slidingWorkAverage.csv
  3. +18
    -0
      data_preparation/cleaned/time_series_days_ranked.csv
  4. +8861
    -0
      data_preparation/cleaned/time_series_rpe_NA_ReplacedWithMedian.csv
  5. +50
    -0
      data_preparation/createWorkSequenceData.R
  6. +1
    -1
      data_preparation/dataPrep.R
  7. +2
    -2
      data_preparation/normalizeData.R
  8. +7
    -1
      data_preparation/readData.R
  9. +56
    -0
      data_preparation/replaceNanWithMedian.R
  10. +31
    -2
      data_preparation/vectorization_ex.py
  11. +33
    -0
      elo_per_day.py

+ 355
- 0
data_preparation/cleaned/fatigue_total_sum.csv View File

@ -0,0 +1,355 @@
,TimeSinceAugFirst,fatigueSum
0,0,0.7344574890035869
1,1,0.4851754722007276
2,2,0.28047459289987386
3,3,0.8528996720285117
4,4,0.06771812799773429
5,5,0.38726124826728237
6,6,0.4668151381247664
7,7,0.7637319478908893
8,8,0.6855120834803765
9,9,0.8951086560274633
10,10,-0.06186187112232838
11,11,0.2963219073909037
12,12,0.6231177621144958
13,13,0.7538292507958928
14,14,0.21787034421122503
15,15,0.5392684904608605
16,16,0.7348439424725517
17,17,0.3084691218711857
18,18,0.1670411353591235
19,19,0.7462678803405148
20,20,0.6227886527763683
21,21,0.2143201560580074
22,22,0.05082785784393374
23,23,0.29424679033220863
24,24,0.18680862419432184
25,25,0.552767197321023
26,26,0.7845417065855602
27,27,0.7794195508511091
28,28,0.7983573737310359
29,29,0.32312904046310925
30,30,0.14514380851555342
31,31,0.6848776416265696
32,32,0.5398747937715528
33,33,0.36321009791782977
34,34,0.48914820446583296
35,35,0.4132365429778073
36,36,0.39501189373141715
37,37,0.15683705077138557
38,38,-0.2855582184594008
39,39,-0.3496985399214124
40,40,-0.5587658361439648
41,41,0.7859411947792441
42,42,0.2608251361668858
43,43,0.17517332439518096
44,44,0.548662507988438
45,45,0.2523212311062572
46,46,0.742763716938104
47,47,0.5298725111377356
48,48,0.3704240285113799
49,49,0.16273339415336321
50,50,0.35710794662067674
51,51,0.012983087373204446
52,52,-0.03899796525449454
53,53,0.24108517993130238
54,54,0.2730510305728201
55,55,0.5012834549713512
56,56,0.35213155414989655
57,57,0.5103081825319213
58,58,0.40841696141170136
59,59,-0.3822596251715601
60,60,0.11178493384173875
61,61,0.6105782657414672
62,62,0.5638365796066905
63,63,0.38703815913988415
64,64,0.17691474265163973
65,65,-0.1584409744032508
66,66,-0.12780884688678903
67,67,0.1676751033705102
68,68,0.23241255411788467
69,69,-0.03403958674123605
70,70,0.36921913242084736
71,71,0.05516608110063374
72,72,-0.1591400757571597
73,73,-0.14381570504980845
74,74,0.30993129245096845
75,75,0.4817187006378433
76,76,0.5426959856634723
77,77,-0.5926098626069284
78,78,-0.08787176009022218
79,79,0.323133612277408
80,80,0.14592673804854944
81,81,0.2660684986755749
82,82,0.11289500622744879
83,83,0.11774653805839017
84,84,0.28998255862081274
85,85,0.1562687777248425
86,86,0.3369601944304925
87,87,0.21156851662268664
88,88,0.4056548888566286
89,89,-0.08065109476753157
90,90,-0.9895032129301133
91,91,-0.6185894832682024
92,92,-0.10635463331522474
93,93,-0.0367041670152624
94,94,-0.19906175862849756
95,95,-0.1653914049490471
96,96,0.4655597131519229
97,97,0.5537123641477566
98,98,0.10718598664191972
99,99,-0.1765203192376061
100,100,-0.01247174683911395
101,101,0.009238546030445893
102,102,0.031210965670767726
103,103,0.306981488185374
104,104,0.3265128063013286
105,105,0.3897899457874447
106,106,0.1633383925102647
107,107,0.43041006311015984
108,108,0.06452962128075361
109,109,-0.05664283933186226
110,110,0.3608106160730567
111,111,0.6744862356360053
112,112,0.20317761835016498
113,113,0.016482187327924346
114,114,0.645937951499796
115,115,-0.635636762766677
116,116,0.05426729872634844
117,117,0.19767824790576916
118,118,-0.037744729883123995
119,119,0.5101843862412544
120,120,0.456725618316876
121,121,0.3694272022261105
122,122,-0.3056942726076881
123,123,-1.0919116910209934
124,124,-0.726910533417431
125,125,-0.4388472873908896
126,126,0.029939288546349287
127,127,-0.06137110272940533
128,128,-0.24552813243807786
129,129,0.009470765956943406
130,130,-0.34178437060398775
131,131,-0.04991936535772925
132,132,0.09714317205897194
133,133,-0.011342193521126434
134,134,0.08042170320790365
135,135,-0.12900441771911692
136,136,-0.27085969616046635
137,137,-0.7089046464519477
138,138,-0.22900902626408856
139,139,-0.1814244389597814
140,140,-0.026564683920244823
141,141,0.2190654841184067
142,142,-0.5304390859264948
143,143,-0.739993065212586
144,144,-0.07814424732831397
145,145,0.2818062549870509
146,146,0.10632331261740126
147,147,0.4610515035246875
148,148,-0.1949608448773015
149,149,-1.032347147920899
150,150,-0.22170874963304332
151,151,-0.14609477120948897
152,152,-0.7698453057085761
153,153,-0.006930021908459132
154,154,-0.10464728372829608
155,155,-0.012381788872798885
156,156,-0.19121232166827026
157,157,-0.6715295272018171
158,158,-0.6163942244984447
159,159,-0.07394318293840786
160,160,0.05714764020354259
161,161,-0.3463306308733807
162,162,-0.08655944015928
163,163,-0.40820283723896816
164,164,-1.2890163326990187
165,165,-1.0620096921743887
166,166,-0.2390787073524069
167,167,-0.06959286135145615
168,168,-0.4705009743846203
169,169,-1.0235076040997462
170,170,-0.38241473575656176
171,171,-0.0919836761123891
172,172,0.01619412513544485
173,173,0.2085579252960514
174,174,0.3826314355942887
175,175,0.0546188605653523
176,176,0.39253931444369095
177,177,0.4073081770793248
178,178,0.5361087576086003
179,179,-0.559118537823889
180,180,-0.04127942580662245
181,181,-0.8119777793283375
182,182,-0.6731101391927786
183,183,-0.6471900326468963
184,184,-0.2640557591258382
185,185,0.21372067089260005
186,186,0.16953292967820452
187,187,0.5728231280292477
188,188,0.5041384981085575
189,189,-0.025148663593221068
190,190,0.2432561651688418
191,191,-0.028600242158835457
192,192,-0.4709730852987265
193,193,-0.40498016732413183
194,194,0.19268730744400392
195,195,0.2491234634614092
196,196,-0.09450139502181923
197,197,0.3301716423691231
198,198,0.30380891634516755
199,199,-0.2258951881744846
200,200,-0.3371851443622679
201,201,0.18456077399231852
202,202,0.10594506304863852
203,203,-0.26826349037309316
204,204,-0.6305855583314973
205,205,-0.45820684078774365
206,206,-0.49815805297679083
207,207,-0.029702307826457188
208,208,-0.06797976527748503
209,209,-0.6569256565250553
210,210,-0.45752927486509876
211,211,-0.27135218581134485
212,212,-1.1165563279167452
213,213,-0.6111669314465557
214,214,-0.6105273765267971
215,215,0.03438253013308448
216,216,-0.14131846494594386
217,217,0.0045112614690663855
218,218,-0.16449239501985058
219,219,-0.05686221199747391
220,220,0.010261586762042467
221,221,0.10108202461301764
222,222,0.37230079653950404
223,223,-0.1458749617004085
224,224,0.06072610620998051
225,225,-0.37105941221648064
226,226,-0.37067009222163605
227,227,0.08311952745889095
228,228,-0.05833898692975855
229,229,0.33629582774049993
230,230,0.5192651216991766
231,231,0.1696838266192163
232,232,0.07748684044191127
233,233,-0.4743646121345583
234,234,-0.24770226914026555
235,235,-0.6595954881299645
236,236,0.26240259376226943
237,237,-0.2779056699659787
238,238,-0.07385767855878048
239,239,0.053602846962544116
240,240,-0.606205677585295
241,241,-0.6240533185483063
242,242,-0.6058672242100481
243,243,-0.2529542976745638
244,244,-0.10133856985122752
245,245,0.13329935585054334
246,246,0.4164696355414681
247,247,-0.48865392999332996
248,248,0.145411566109825
249,250,-0.7273385231793927
250,251,0.12410412032198169
251,252,0.27674868329463415
252,253,0.7933817709056039
253,254,0.6430634141972724
254,255,1.0498918584797523
255,256,0.16433766740443653
256,257,0.1581754209003413
257,258,-0.3767844129570323
258,259,-1.13446825563484
259,260,-0.682110266582935
260,261,0.03890579636217944
261,262,0.25070534761643054
262,263,0.6308354888129499
263,264,-0.3811854765459816
264,265,-2.0947320525204836
265,266,-1.0842354860084216
266,267,-1.0043510999282745
267,268,-0.9692235311586099
268,269,-0.8451134775394933
269,270,-0.5423262674604377
270,271,-0.15428902367855632
271,272,-0.47818347594846994
272,273,-0.3061862272276976
273,274,0.13016558778888693
274,275,-0.5346074316667073
275,276,-0.024108562029164497
276,277,0.44135660385783515
277,278,0.8359742523934252
278,279,0.5047436125815261
279,280,0.6080841302618076
280,281,0.35428669835871673
281,282,0.1490984551391564
282,283,0.3628666490409816
283,284,0.5851070995519784
284,285,-0.23884955785828602
285,286,-1.2931620504440084
286,287,-0.5149710038459224
287,288,-0.13060527178434828
288,289,0.05460102315917359
289,290,0.7126540531525146
290,291,0.3454110915997969
291,292,0.5908276470938011
292,293,0.22617556533671632
293,294,0.06645643211862166
294,295,-0.24410962776969897
295,296,-0.6686078186408764
296,297,-0.8927537790976293
297,298,-0.8644506239971387
298,299,-0.0526291051689912
299,300,0.09787954027186502
300,301,0.06886122334331811
301,302,0.20130318055109625
302,303,-0.3433112649541869
303,304,-0.14959798865436585
304,305,0.15919756672149993
305,306,-0.1280300468277571
306,307,-0.8817613473908142
307,308,0.11091144515390736
308,309,-0.059481544970225834
309,310,0.24826104657910567
310,311,0.21782917177756106
311,312,-0.1687691177431938
312,313,-0.7343025362546837
313,314,-1.233666925895062
314,315,-0.4250094786650305
315,316,-0.23695666543827143
316,317,-0.13528794113346507
317,318,-0.21467610436495208
318,319,-0.2465124428901275
319,320,0.02001698597605328
320,321,-0.5611020124713038
321,322,-0.25833755332807773
322,323,-0.36020138367026094
323,324,-0.6767581793070323
324,325,-1.2232671693259605
325,326,-0.5524980778772826
326,327,-0.0593829242117204
327,328,-0.2301741460847353
328,329,-0.17812573297568593
329,330,-0.7822181509887379
330,331,-0.9027716053209451
331,332,-0.8341775858590699
332,333,-0.6237422947183584
333,334,0.029100211618237018
334,335,-0.2769984632439794
335,336,-0.4956169729129575
336,337,-0.16842928848013955
337,338,-0.21520559276700027
338,339,-0.40092940485044154
339,340,0.0014212864891760299
340,341,0.24764616251080407
341,342,-0.0198326678170691
342,343,0.41449646066539014
343,344,0.30521758335133714
344,345,0.2603758932210191
345,346,0.6435856062574784
346,347,0.5875025644973848
347,348,0.9333689916536452
348,349,0.5629340431788956
349,350,0.5822132331979378
350,351,0.5505608569805795
351,352,0.5982805951374118
352,353,0.7396982091655812
353,354,0.066689402177346

+ 336
- 0
data_preparation/cleaned/slidingWorkAverage.csv View File

@ -0,0 +1,336 @@
"","TimeSinceAugFirst","slidingWorkAverage"
"1",20,5563.95
"2",21,5895.66666666667
"3",22,6307.42857142857
"4",23,6331.71428571429
"5",24,6458.52380952381
"6",25,6752.33333333333
"7",26,6767.33333333333
"8",27,6766.61904761905
"9",28,6738.42857142857
"10",29,6798.66666666667
"11",30,6811.38095238095
"12",31,6813.7619047619
"13",32,6881.85714285714
"14",33,6840.42857142857
"15",34,6834.71428571429
"16",35,6788.47619047619
"17",36,6711.09523809524
"18",37,6720.61904761905
"19",38,6781.33333333333
"20",39,6495.04761904762
"21",40,6617.90476190476
"22",41,6578.85714285714
"23",42,6122.66666666667
"24",43,5613.04761904762
"25",44,5671
"26",45,5383.2380952381
"27",46,4878.52380952381
"28",47,4872.90476190476
"29",48,4874.33333333333
"30",49,4910.85714285714
"31",50,4796.80952380952
"32",51,4867.42857142857
"33",52,5067.90476190476
"34",53,5234.04761904762
"35",54,5216.19047619048
"36",55,5235.47619047619
"37",56,5313.09523809524
"38",57,5416.90476190476
"39",58,5454.90476190476
"40",59,5578.47619047619
"41",60,5850.80952380952
"42",61,5744.38095238095
"43",62,5768.66666666667
"44",63,6210.71428571429
"45",64,6592.95238095238
"46",65,6613.90476190476
"47",66,6986.7619047619
"48",67,7557.09523809524
"49",68,7567.71428571429
"50",69,7583.42857142857
"51",70,7640.33333333333
"52",71,7712.38095238095
"53",72,7741.19047619048
"54",73,7612.85714285714
"55",74,7466
"56",75,7487.42857142857
"57",76,7480.28571428571
"58",77,7064.61904761905
"59",78,6618.42857142857
"60",79,6647.38095238095
"61",80,6575.95238095238
"62",81,5935.85714285714
"63",82,6326.33333333333
"64",83,7005.38095238095
"65",84,6509.52380952381
"66",85,6314.66666666667
"67",86,6331
"68",87,5901.95238095238
"69",88,5370.85714285714
"70",89,5633.80952380952
"71",90,5935.52380952381
"72",91,5317.66666666667
"73",92,4865.38095238095
"74",93,4682.7619047619
"75",94,4640.61904761905
"76",95,4585.61904761905
"77",96,4604.66666666667
"78",97,4592.52380952381
"79",98,5018.95238095238
"80",99,5509.19047619048
"81",100,5545.38095238095
"82",101,5570.52380952381
"83",102,6642.42857142857
"84",103,6281.95238095238
"85",104,5579.19047619048
"86",105,6177.7619047619
"87",106,6478.2380952381
"88",107,6441.33333333333
"89",108,7018.95238095238
"90",109,7771.09523809524
"91",110,7487.42857142857
"92",111,7168.57142857143
"93",112,7570.95238095238
"94",113,7856.38095238095
"95",114,7973.7619047619
"96",115,7617.33333333333
"97",116,7176.85714285714
"98",117,7260.66666666667
"99",118,7479.2380952381
"100",119,7162.33333333333
"101",120,6722.57142857143
"102",121,6734.71428571429
"103",122,6630
"104",123,6050.57142857143
"105",124,6004.14285714286
"106",125,6003.57142857143
"107",126,5477.38095238095
"108",127,4982.38095238095
"109",128,4995.71428571429
"110",129,4822.14285714286
"111",130,4590
"112",131,4634.28571428571
"113",132,4634.28571428571
"114",133,4787.61904761905
"115",134,4950.19047619048
"116",135,5018.52380952381
"117",136,5628.90476190476
"118",137,6380.04761904762
"119",138,6255.7619047619
"120",139,6037.19047619048
"121",140,6435.90476190476
"122",141,6408.04761904762
"123",142,6788.90476190476
"124",143,6869.19047619048
"125",144,6356.95238095238
"126",145,6463.14285714286
"127",146,6653.61904761905
"128",147,6511.71428571429
"129",148,6512.95238095238
"130",149,6397.71428571429
"131",150,6617.2380952381
"132",151,6094.85714285714
"133",152,6766.28571428571
"134",153,6873.19047619048
"135",154,6273.19047619048
"136",155,6500.61904761905
"137",156,6401.80952380952
"138",157,6452.2380952381
"139",158,6449.42857142857
"140",159,6518
"141",160,6518
"142",161,6399.7619047619
"143",162,6653.19047619048
"144",163,6260.19047619048
"145",164,6179.2380952381
"146",165,6804.2380952381
"147",166,6751.14285714286
"148",167,6560.66666666667
"149",168,6990.90476190476
"150",169,6975.14285714286
"151",170,6970.14285714286
"152",171,6734.80952380952
"153",172,6583.04761904762
"154",173,6174.2380952381
"155",174,6067.33333333333
"156",175,6419.2380952381
"157",176,6005.47619047619
"158",177,5965.57142857143
"159",178,5539.04761904762
"160",179,5201.80952380952
"161",180,5306
"162",181,5357.33333333333
"163",182,4840.19047619048
"164",183,4516.04761904762
"165",184,4437.38095238095
"166",185,4148.19047619048
"167",186,3595.90476190476
"168",187,3589
"169",188,3614.71428571429
"170",189,3615.90476190476
"171",190,4194.09523809524
"172",191,4347.19047619048
"173",192,4576.33333333333
"174",193,5244.28571428571
"175",194,4937.38095238095
"176",195,4937.38095238095
"177",196,5191.42857142857
"178",197,5533.57142857143
"179",198,5683.71428571429
"180",199,5955.38095238095
"181",200,6318.57142857143
"182",201,6214.85714285714
"183",202,6167.80952380952
"184",203,6524.47619047619
"185",204,6826.14285714286
"186",205,6846.95238095238
"187",206,6975.66666666667
"188",207,7325.80952380952
"189",208,7488.04761904762
"190",209,7584.71428571429
"191",210,7458.04761904762
"192",211,6931.52380952381
"193",212,6847.33333333333
"194",213,6665.90476190476
"195",214,6637.09523809524
"196",215,6637.09523809524
"197",216,6637.09523809524
"198",217,6707.80952380952
"199",218,6657.04761904762
"200",219,6630.80952380952
"201",220,6465.09523809524
"202",221,5746.7619047619
"203",222,5677.71428571429
"204",223,5673.42857142857
"205",224,6052.2380952381
"206",225,6061.28571428571
"207",226,6100.90476190476
"208",227,6407.80952380952
"209",228,6582.80952380952
"210",229,6400.09523809524
"211",230,6277.71428571429
"212",231,5974.61904761905
"213",232,6039.85714285714
"214",233,6138.61904761905
"215",234,5793.95238095238
"216",235,5185.61904761905
"217",236,5185.61904761905
"218",237,5185.61904761905
"219",238,5011.33333333333
"220",239,4762.33333333333
"221",240,4749.28571428571
"222",241,4999.7619047619
"223",242,5391.90476190476
"224",243,5391.90476190476
"225",244,5391.90476190476
"226",245,5236.42857142857
"227",246,5204.09523809524
"228",247,5067.57142857143
"229",248,4865.90476190476
"230",249,4221.85714285714
"231",250,4196.14285714286
"232",251,4287.33333333333
"233",252,4549.61904761905
"234",253,4529.61904761905
"235",254,4321.95238095238
"236",255,4376.2380952381
"237",256,4534.95238095238
"238",257,4642.28571428571
"239",258,4867.95238095238
"240",259,4410.66666666667
"241",260,4181.7619047619
"242",261,4132
"243",262,3547.95238095238
"244",263,3165.57142857143
"245",264,3537.19047619048
"246",265,3752.71428571429
"247",266,3212
"248",267,3017.04761904762
"249",268,3013.47619047619
"250",269,2987.04761904762
"251",270,3462.28571428571
"252",271,3469.42857142857
"253",272,3391.09523809524
"254",273,3847.14285714286
"255",274,4045.71428571429
"256",275,4249.85714285714
"257",276,4280.47619047619
"258",277,4291.42857142857
"259",278,4184.09523809524
"260",279,3958.42857142857
"261",280,4075.47619047619
"262",281,4352.66666666667
"263",282,4394.80952380952
"264",283,4441.95238095238
"265",284,4476.2380952381
"266",285,4435.66666666667
"267",286,4468.14285714286
"268",287,4414.09523809524
"269",288,4349
"270",289,4450.19047619048
"271",290,4178.04761904762
"272",291,3862.09523809524
"273",292,3881.38095238095
"274",293,3871.38095238095
"275",294,3611.19047619048
"276",295,3662.61904761905
"277",296,3575.85714285714
"278",297,3918.2380952381
"279",298,4170.2380952381
"280",299,4170.2380952381
"281",300,4170.2380952381
"282",301,4577.85714285714
"283",302,4423.38095238095
"284",303,4388.38095238095
"285",304,4756.47619047619
"286",305,4869.19047619048
"287",306,4538.14285714286
"288",307,4290.14285714286
"289",308,4433.2380952381
"290",309,4762.28571428571
"291",310,4642.71428571429
"292",311,4739.61904761905
"293",312,4890.19047619048
"294",313,4977.90476190476
"295",314,5076.2380952381
"296",315,4817.2380952381
"297",316,4391.52380952381
"298",317,4344.14285714286
"299",318,4162.71428571429
"300",319,4213.19047619048
"301",320,4247.85714285714
"302",321,4270.42857142857
"303",322,4225.42857142857
"304",323,4455.19047619048
"305",324,4327.80952380952
"306",325,4272.80952380952
"307",326,4688.19047619048
"308",327,4688.19047619048
"309",328,4688.19047619048
"310",329,5210.80952380952
"311",330,5324.14285714286
"312",331,5318.71428571429
"313",332,5487.85714285714
"314",333,5625.85714285714
"315",334,5602.42857142857
"316",335,5535.52380952381
"317",336,5745.47619047619
"318",337,6030.2380952381
"319",338,5963.57142857143
"320",339,5825
"321",340,5540.95238095238
"322",341,5506.28571428571
"323",342,5496.09523809524
"324",343,5394.66666666667
"325",344,5061.95238095238
"326",345,5061.2380952381
"327",346,4868.61904761905
"328",347,4190.04761904762
"329",348,4192.90476190476
"330",349,4192.90476190476
"331",350,3631.2380952381
"332",351,3369.09523809524
"333",352,3366.2380952381
"334",353,3131.38095238095
"335",354,2723.52380952381

+ 18
- 0
data_preparation/cleaned/time_series_days_ranked.csv View File

@ -0,0 +1,18 @@
,Date,DailyElo
0,121,0.0
1,122,-3.714599999999998
2,178,0.04346000000000028
3,179,2.1916710000000013
4,180,0.0
5,255,0.0
6,256,0.0
7,257,-2.520374784999996
8,263,-2.0880156214999985
9,264,-1.7032140593500005
10,284,-0.6130256153877235
11,285,2.620463284090865
12,311,-2.076954630427971
13,312,1.0960590427574828
14,313,1.8954531384817344
15,353,-0.2940921753664384
16,354,-1.8646829578297937

+ 8861
- 0
data_preparation/cleaned/time_series_rpe_NA_ReplacedWithMedian.csv
File diff suppressed because it is too large
View File


+ 50
- 0
data_preparation/createWorkSequenceData.R View File

@ -0,0 +1,50 @@
source("readData.R")
library(tidyverse)
RPEData <-readNArpeData()
numDays <- max(RPEData$TimeSinceAugFirst)
dayList <- 0:numDays
workLoad <- c()
averageWorkLoad <- c()
for(day in dayList)
{
total <- 0
daylyActivities <- subset(RPEData, TimeSinceAugFirst == day)
cat("day: ", day, "\n",sep="")
cat("Activity count:", length(daylyActivities$DailyLoad), "\n", sep="")
averageWorkLoad <- c(averageWorkLoad, mean(daylyActivities$SessionLoad, na.rm = T))
workLoad <- c(workLoad, sum(daylyActivities$SessionLoad, na.rm = T))
}
plot(dayList, averageWorkLoad, main="Average Work Load")
plot(dayList, workLoad, main="Daily Total Work Load")
slidingAverage <- c()
window <- 21 - 1
for(day in window:numDays)
{
print(length(workLoad[c((day-window):day)]))
windowAverage <- mean(workLoad[c((day-window):day)])
slidingAverage <- c(slidingAverage, windowAverage)
}
plot(window:numDays, slidingAverage, main="Sliding Average")
plot(density(slidingAverage), main="Sliding Average Density")
plot(density(workLoad), main="Total Work Load Average")
dataTibble <- tibble(TimeSinceAugFirst = window:numDays, slidingWorkAverage = slidingAverage)
write.csv(dataTibble, "cleaned/slidingWorkAverage.csv")

+ 1
- 1
data_preparation/dataPrep.R View File

@ -7,7 +7,7 @@ library(tidyverse)
library(DBI) library(DBI)
library(RSQLite) library(RSQLite)
gpsData <- read.csv("data/gps.csv")
gpsData <- read.csv("data/gps.csv")c
gpsDataTibble <- as_tibble(gpsData) gpsDataTibble <- as_tibble(gpsData)

+ 2
- 2
data_preparation/normalizeData.R View File

@ -83,11 +83,11 @@ for(id in playerIds)
} }
normalWellnessData <- tibble(date = normDate, playerID = normPlayerIDs, normSoreness = normSoreness,
normalWellnessData <- tibble(TimeSinceAugFirst = normDate, playerID = normPlayerIDs, normSoreness = normSoreness,
normFatigue = normFatigue, normDesire = normDesire, normIrritability = normIrritability, normFatigue = normFatigue, normDesire = normDesire, normIrritability = normIrritability,
normSleepHours = normSleepHours, normSleepQuality = normSleepQuality) normSleepHours = normSleepHours, normSleepQuality = normSleepQuality)
write.csv(normalWellnessData, "cleaned/normalizedWellness.csv")
write.csv(normalWellnessData, "cleaned/time_series_normalized_wellness.csv")
plot() plot()

+ 7
- 1
data_preparation/readData.R View File

@ -13,5 +13,11 @@ readWellnessData <- function()
readRPEData <- function() readRPEData <- function()
{ {
as_tibble(read.csv("./cleaned/notnormalized_with_0Nan_rpe.csv"))
as_tibble(read.csv("./cleaned/time_series_notnormalized_with_continuousNan_rpe.csv"))
}
readNArpeData <- function()
{
as_tibble(read.csv("./cleaned/time_series_notnormalized_with_continuousNan_rpe.csv"))
} }

+ 56
- 0
data_preparation/replaceNanWithMedian.R View File

@ -0,0 +1,56 @@
source("readData.R")
library(tidyverse)
# file to replace NA values with the median for thet column
trainingData <- readRPEData()
#duration
trainingData$Duration[is.na(trainingData$Duration)] <- median(trainingData$Duration, na.rm=TRUE)
print(trainingData$Duration)
#RPE
trainingData$RPE[is.na(trainingData$RPE)] <- median(trainingData$RPE, na.rm=TRUE)
# acute load
trainingData$AcuteLoad[is.na(trainingData$AcuteLoad)] <- median(trainingData$AcuteLoad, na.rm=TRUE)
# chronic load
trainingData$ChronicLoad[is.na(trainingData$ChronicLoad)] <- median(trainingData$ChronicLoad, na.rm=TRUE)
# ratio
trainingData$AcuteChronicRatio[is.na(trainingData$AcuteChronicRatio)] <- median(trainingData$AcuteChronicRatio, na.rm=TRUE)
# objective rating
trainingData$ObjectiveRating[is.na(trainingData$ObjectiveRating)] <- median(trainingData$ObjectiveRating, na.rm=TRUE)
# focus rating
trainingData$FocusRating[is.na(trainingData$FocusRating)] <- median(trainingData$FocusRating, na.rm=TRUE)
# session load
trainingData$SessionLoad[is.na(trainingData$SessionLoad)] <- median(trainingData$SessionLoad, na.rm=TRUE)
# daily load
trainingData$DailyLoad[is.na(trainingData$DailyLoad)] <- median(trainingData$DailyLoad, na.rm=TRUE)
trainingData$RPE[is.na(trainingData$RPE)] <- median(trainingData$RPE, na.rm=TRUE)
write.csv(as.data.frame(trainingData), "cleaned/time_series_rpe_NA_ReplacedWithMedian.csv")
head(as.data.frame(trainingData), 100)
trainingData

+ 31
- 2
data_preparation/vectorization_ex.py View File

@ -47,5 +47,34 @@ class WellnessCSV:
df.to_csv(self.end) df.to_csv(self.end)
cls = WellnessCSV()
cls.vectorize()
class FatigueSum:
def __init__(self):
self.file = "cleaned/time_series_normalized_wellness.csv"
self.end = "cleaned/fatigue_total_sum.csv"
def calculate(self):
df = pd.read_csv(self.file)
# get some of the fatigue for a particular date
diction = dict()
dates = df["TimeSinceAugFirst"].unique()
dates = set(dates)
dates = list(dates)
# for each date, get unique data and get calculation
for date in dates:
pdf = df[df["TimeSinceAugFirst"] == date]
num_players = len(pdf["playerID"].unique())
fatigue_sum = pdf["normFatigue"].sum()
result = fatigue_sum / num_players
diction[date] = result
# Converting
dates = diction.keys()
values = diction.values()
final_df = pd.DataFrame()
final_df["TimeSinceAugFirst"] = dates
final_df["fatigueSum"] = values
final_df.to_csv(self.end)

+ 33
- 0
elo_per_day.py View File

@ -0,0 +1,33 @@
import numpy as np
import pandas as pd
def join_cols():
# Reads in csv files to be manipulated
dfg = pd.read_csv('data_preparation/data/games_ranked.csv')
# Creates the new dataframe where each date is a unique column, and gets the number of dates
unique_dates = pd.DataFrame(dfg["Date"].unique()).to_numpy()
unique_rows = unique_dates.shape[0]
daily_elos = np.array(unique_rows).astype(float)
print(unique_rows)
# Creates two numpy arrays to perform some operations on
dates = dfg["Date"].to_numpy()
e_change = dfg["eloChangeAdjusted"].to_numpy()
rows = dates.shape()[0]
# sums up the elo change on a given day and then exports it to a unique .csv file
x = 0
for i in range(0, rows):
if not (dates[i] == unique_dates[x]):
x = x + 1
daily_elos[x] = daily_elos[x] + e_change[i]
# Creates a new dataframe from the two unique date array and the daily elo change array
df_dec = pd.DataFrame()
df_dec["Date"] = unique_dates
df_dec["DailyElo"] = daily_elos
print(df_dec)

Loading…
Cancel
Save