nglod33 5 years ago
parent
commit
46c5475ad1
7 changed files with 6289 additions and 6041 deletions
  1. +152
    -0
      data_preparation/IndividualMetrics.R
  2. +6036
    -6036
      data_preparation/cleaned/personal.csv
  3. +28
    -0
      data_preparation/exponentialSmoothing.R
  4. BIN
      findings/clusterMess.png
  5. BIN
      findings/plots/Rplot08.png
  6. +56
    -0
      hypotheses_modeling/ryan_regressions.txt
  7. +17
    -5
      hypotheses_modeling/team_regressions.py

+ 152
- 0
data_preparation/IndividualMetrics.R View File

@ -0,0 +1,152 @@
source("readData.R")
library(tidyverse)
RPEData <-readNArpeData()
wellnessData <- readWellnessData()
normalizedWellnessData <- readNormalizedMetrics()
RPEData
playerIDS <- playerIds <-unique(RPEData$PlayerID)
numDays <- max(RPEData$TimeSinceAugFirst)
dayList <- 0:numDays
dayCol <- c()
playerid <- c()
dailyLoadCol <- c()
acuteChronicRatioCol <- c()
trainDuration <- c()
sleepHoursCol <- c()
fatigueRawCol <- c()
sleepQualityCol <- c()
sorenessCol <- c()
normFatCol <-c()
normSoreCol <- c()
normSleepHours <- c()
normSleepQuality <- c()
notatAllCol <- c()
absCol <-c()
somewhatCol <- c()
unknownCol <- c()
for(day in dayList)
{
for(id in playerIDS)
{
cat("Player:", id, "Day:", day, "\n", sep=" ")
trainDay <- subset(RPEData, TimeSinceAugFirst == day & PlayerID == id)
#workLoad <- c(workLoad, sum(daylyActivities$SessionLoad, na.rm = T))
wellnessDay <- subset(wellnessData, TimeSinceAugFirst == day & PlayerID == id)
normalizedDay <- subset(normalizedWellnessData, TimeSinceAugFirst == day & playerID == id)
#if(length(normalizedDay$playerID) > 0)
#{
# print("good")
#}
dayCol <- c(dayCol, day)
playerid <- c(playerid, id)
if(length(wellnessDay$SleepHours) > 0)
{
fatigueRawCol <- c(fatigueRawCol, mean(wellnessDay$Fatigue, na.rm =T))
sleepQualityCol <- c(sleepQualityCol, mean(wellnessDay$SleepQuality, na.rm = T))
sleepHoursCol <- c(sleepHoursCol, sum(wellnessDay$SleepHours, na.rm = T))
sorenessCol <- c(sorenessCol, mean(wellnessDay$Soreness, na.rm = T))
}
else
{
sleepQualityCol <- c(sleepQualityCol, median(wellnessData$SleepQuality, na.rm = T))
sleepHoursCol <- c(sleepHoursCol, median(wellnessData$SleepHours))
fatigueRawCol <- c(fatigueRawCol, median(wellnessData$Fatigue))
sorenessCol <- c(sorenessCol, median(wellnessData$Soreness))
}
if(length(normalizedDay$normSoreness) > 0)
{
normFatCol <- c(normFatCol, mean(normalizedDay$normFatigue, na.rm=T))
normSoreCol <- c(normSoreCol, mean(normalizedDay$normSoreness, na.rm = T))
normSleepHours <- c(normSleepHours, mean(normalizedDay$normSleepHours, na.rm =T))
normSleepQuality <- c(normSleepQuality, mean(normalizedDay$normSleepQuality, na.rm=T))
}
else
{
normFatCol <- c(normFatCol, mean(normalizedWellnessData$normFatigue, na.rm=T))
normSoreCol <- c(normSoreCol, mean(normalizedWellnessData$normSoreness, na.rm = T))
normSleepHours <- c(normSleepHours, mean(normalizedWellnessData$normSleepHours, na.rm =T))
normSleepQuality <- c(normSleepQuality, mean(normalizedWellnessData$normSleepQuality, na.rm=T))
}
if(length(trainDay$SessionLoad) > 0)
{
dailyLoadCol <- c(dailyLoadCol, mean(trainDay$DailyLoad,na.rm = T))
acuteChronicRatioCol <- c(acuteChronicRatioCol, mean(trainDay$AcuteChronicRatio, na.rm =T))
trainDuration <- c(trainDuration, sum(trainDay$Duration, na.rm = T))
notatAllCol <- c(notatAllCol, max(trainDay$BestOutOfMyselfNotAtAll))
absCol <- c(absCol, max(trainDay$BestOutOfMyselfAbsolutely))
somewhatCol <- c(somewhatCol, max(trainDay$BestOutOfMyselfSomewhat))
unknownCol <- c(unknownCol, max(trainDay$BestOutOfMyselfUnknown))
}
else
{
dailyLoadCol <- c(dailyLoadCol, 0)
acuteChronicRatioCol <- c(acuteChronicRatioCol, 0)
trainDuration <- c(trainDuration, 0)
notatAllCol <- c(notatAllCol, 0)
absCol <- c(absCol, 0)
somewhatCol <- c(somewhatCol, 0)
unknownCol <- c(unknownCol, 1)
}
}
}
dailyLoadCol[is.na(dailyLoadCol)] <- 0
acuteChronicRatioCol[is.na(acuteChronicRatioCol)] <- 0
massiveTibble <- tibble(day = dayCol,
playerID = playerid,
DailyLoad = dailyLoadCol,
acuteChronicRatio = acuteChronicRatioCol,
trainDuration = trainDuration,
sleepHours = sleepHoursCol,
fatigue = fatigueRawCol,
sleepQuality = sleepQualityCol,
soreness = sorenessCol,
fatigueNorm = normFatCol,
sorenessNorm = normSoreCol,
sleepHoursNorm = normSleepHours,
sleepQualityNorm = normSleepQuality,
BestOutOfMyselfNotAtAll = notatAllCol,
BestOutOfMyselfAbsolutely = absCol,
BestOutOfMyselfSomewhat = somewhatCol,
BestOutOfMyselfUnknown = unknownCol)
write.csv(massiveTibble, "cleaned/personal.csv")

+ 6036
- 6036
data_preparation/cleaned/personal.csv
File diff suppressed because it is too large
View File


+ 28
- 0
data_preparation/exponentialSmoothing.R View File

@ -0,0 +1,28 @@
fatigueFunction <- function(workLoad, index)
{
if(index == 1)
{
return(workLoad[1])
}
else
{
return(workLoad[index] + 0.7*fatigueFunction(workLoad, index -1))
}
}
smoothVector <- function(dataV)
{
dataNew <- c()
for(i in 1:length(dataV))
{
dataNew <- c(dataNew, fatigueFunction(dataV, i))
}
dataNew
}
smoothVector(c(1,2,3,4))
plot(1:100, smoothVector(1:100))

BIN
findings/clusterMess.png View File

Before After
Width: 1000  |  Height: 1000  |  Size: 151 KiB

BIN
findings/plots/Rplot08.png View File

Before After
Width: 824  |  Height: 532  |  Size: 94 KiB

+ 56
- 0
hypotheses_modeling/ryan_regressions.txt View File

@ -0,0 +1,56 @@
Player 9 for acuteChronicRatio
(1.5543991777375237, array([-0.13902363, -0.0050734 ]), 0.43833525766886916, 0.0008867324974165428)
(0.48957502323211444, 0.5699208996736808)
Player 11 for acuteChronicRatio
(1.3258336437888891, array([ 0.00685405, -0.00203877]), 0.11479264860906191, 0.00096573215060248)
(0.4626369870793939, 0.44423100028132423)
Player 9 for sleepQuality
(5.334340148618029, array([ 1.02125114, -0.00432071]), 0.6539555377710119, 0.0012466268315319546)
(0.597372726628557, 0.7193845945200593)
Player 12 for sleepQuality
(3.584632145668627, array([0.41485048, 0.00088306]), 0.34499328173976607, 0.0006803191826778461)
(0.4600451787749952, 0.4227561697627662)
Player 3 for soreness
(3.2022109874813864, array([ 4.19185564e-01, -1.39780603e-04]), 0.4252210971285296, 0.0006688273367686844)
(0.4674558844267985, 0.468022382169041)
Player 7 for soreness
(3.077085467389001, array([4.26722267e-01, 5.78941104e-05]), 0.39740866670470376, 0.0007515523424419748)
(0.49988907759269197, 0.4324080355741665)
Player 9 for soreness
(5.246967544538162, array([ 0.71359643, -0.00715268]), 0.5944763974272957, 0.0019117577400940124)
(0.7765705044770445, 0.637614880294574)
Player 3 for sorenessNorm
(0.12141700921277873, array([ 0.58776641, -0.00068588]), 0.36954097046558354, 0.0017457549720592538)
(0.7372571250720799, 0.443920566690573)
Player 9 for sleepQualityNorm
(0.08976795719049747, array([ 7.62990183e-01, -4.56901189e-04]), 0.5858342550214043, 0.0005114756024138036)
(0.40337948626285336, 0.6267479812123391)
Player 12 for sleepQualityNorm
(0.0030010445831953553, array([ 5.97640029e-01, -1.59341568e-05]), 0.3568843263232311, 0.00117522635306064)
(0.6154637522814207, 0.4127840710858218)
Player 3 for BestOutOfMyselfAbsolutely
(0.5591113560131244, array([-0.06273135, 0.00144052]), 0.19693367374327753, 0.00034431962962114574)
(0.29946330051959735, 0.4074811906349808)
Player 9 for BestOutOfMyselfAbsolutely
(0.6212790914046262, array([ 0.23297634, -0.00209794]), 0.49210290965481174, 0.0002682490835151878)
(0.2897694328560262, 0.5496315964616945)
Player 3 for BestOutOfMyselfUnknown
(0.45258982162191874, array([ 0.0601493 , -0.00149072]), 0.20252316026232742, 0.0003459027048924739)
(0.2980996120964688, 0.41962026820540466)
Player 9 for BestOutOfMyselfUnknown
(0.34069195794958324, array([-0.22074479, 0.00217018]), 0.4646199842752917, 0.0003011772648087732)
(0.3048702214016301, 0.5319467359793901)

+ 17
- 5
hypotheses_modeling/team_regressions.py View File

@ -60,12 +60,24 @@ def poly_regression(x, y, degree):
def main():
file = open("ryan_regressions.txt", 'w')
player = pd.read_csv("../data_preparation/cleaned/personal.csv", index_col=0)
player = player[player['playerID'] == 1]
x = player[['fatigueNorm', 'day']]
y = player['sorenessNorm']
print(standard_lr(x, y))
print(poly_regression(x, y, 5))
for name, value in player.iteritems():
if name == "day":
continue
for j in range(1, 17):
ply = player[player['playerID'] == j]
x = ply[['fatigueNorm', 'day']]
y = ply[name]
lr = standard_lr(x, y)
poly = poly_regression(x, y, 3)
if .9 > lr[2] > .4 or .9 > poly[1] > .4:
file.write("Player {} for {}\n".format(j, name))
file.write("{}\n".format(lr))
file.write("{}\n\n".format(poly))
if __name__ == "__main__":

Loading…
Cancel
Save