[chronojump] Initial testing with world chanpionships data
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Initial testing with world chanpionships data
- Date: Sat, 16 Jan 2021 10:37:34 +0000 (UTC)
commit eb1f089a61b0fc0b556602df0fb38cd156d2fc00
Author: Xavier Padullés <testing chronojump org>
Date: Fri Dec 18 16:22:26 2020 +0100
Initial testing with world chanpionships data
.../shortsLibrary/WorlChampionshipSplitTimes.csv | 18 +++
r-scripts/tests/shortsLibrary/learningShorts.R | 5 +-
r-scripts/tests/shortsLibrary/validation.R | 126 +++++++++++++++++++++
3 files changed, 148 insertions(+), 1 deletion(-)
---
diff --git a/r-scripts/tests/shortsLibrary/WorlChampionshipSplitTimes.csv
b/r-scripts/tests/shortsLibrary/WorlChampionshipSplitTimes.csv
new file mode 100644
index 00000000..c245af42
--- /dev/null
+++ b/r-scripts/tests/shortsLibrary/WorlChampionshipSplitTimes.csv
@@ -0,0 +1,18 @@
+Year;Name;Surname;RT;T10;T20;T30;T40;T50;T60;T70;T80;T90;T100
+1987;Ben;Johnson;129;1,71;2,73;3,67;4,54;5,4;6,25;7,1;7,97;8,83;9,7
+1987;Carl;Lewis;193;1,75;2,77;3,72;4,59;5,45;6,31;7,17;8,03;8,88;9,74
+1991;Carl;Lewis;0,14;1,74;2,82;3,74;4,63;5,47;6,32;7,16;7,99;8,86;9,72
+1991;Leroy;Burrell;0,12;1,71;2,77;3,67;4,56;5,43;6,29;7,14;8;8,89;9,76
+1991;Dennis;Mitchell;0,09;1,71;2,78;3,71;4,59;5,46;6,33;7,19;8,05;8,92;9,81
+1997;Maurice;Greene;0,13;1,71;2,75;3,67;4,55;5,42;6,27;7,12;7,98;8,85;9,73
+1997;Donovan;Bailey;0,14;1,78;2,81;3,72;4,59;5,44;6,29;7,14;8;8,87;9,77
+1997;Tim;Montgomery;0,13;1,73;2,76;3,69;4,57;5,43;6,29;7,15;8,02;8,9;9,8
+1997;Frank;Fredericks;0,12;1,73;2,77;3,7;4,59;5,46;6,32;7,18;8,05;8,93;9,82
+1997;Ato;Boldon;0,12;1,72;2,77;3,7;4,59;5,46;6,33;7,2;8,08;8,98;9,9
+1999;Maurice;Greene;132;1,73;2,76;3,67;4,56;5,42;6,27;7,11;7,96;8,81;9,67
+1999;Bruny;Surin;127;1,75;2,75;3,67;4,56;5,41;6,25;7,12;7,98;8,84;9,72
+1999;Obadele;Thompson;145;1,77;2,79;3,71;4,62;5,49;6,36;7,22;8,1;8,98;9,86
+1999;Tim;Harden;136;1,74;2,76;3,67;4,58;5,47;6,34;7,2;8,09;8,98;9,89
+1999;Tim;Montgomery;136;1,78;2,82;3,75;4,64;5,52;6,39;7,26;8,15;9,03;9,91
+1999;Jason;Gardner;142;1,77;2,79;3,71;4,6;5,48;6,37;7,26;8,14;9,03;9,93
+1999;Kareem;Streete-Thompson;173;1,8;2,82;3,76;4,66;5,55;6,44;7,33;8,21;9,14;10,07
diff --git a/r-scripts/tests/shortsLibrary/learningShorts.R b/r-scripts/tests/shortsLibrary/learningShorts.R
index 83a21656..2c314cd2 100644
--- a/r-scripts/tests/shortsLibrary/learningShorts.R
+++ b/r-scripts/tests/shortsLibrary/learningShorts.R
@@ -1,14 +1,17 @@
require(shorts)
bolt = data.frame(distance = c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
- , time = c(1.85, 1.02, 0.91, 0.87, 0.85, 0.82, 0.82, 0.82, 0.83, 0.90))
+ , time = cumsum(c(1.85, 1.02, 0.91, 0.87, 0.85, 0.82, 0.82, 0.82, 0.83, 0.90)))
bolt = data.frame(time = bolt$time, position = bolt$distance, distance = bolt$distance)
+WorlChampionshipSplitTimes <-
read.csv2("~/chronojump/r-scripts/tests/shortsLibrary/WorlChampionshipSplitTimes.csv")
+
split_times3 <- data.frame(
distance = c(10, 20, 30),
time = c(1.614, 2.821, 3.966)
)
+
# get the model adjusting the time_correction to the best fit
getModelWithOptimalTimeCorrection <- function(split_times)
{
diff --git a/r-scripts/tests/shortsLibrary/validation.R b/r-scripts/tests/shortsLibrary/validation.R
new file mode 100644
index 00000000..764f3fa0
--- /dev/null
+++ b/r-scripts/tests/shortsLibrary/validation.R
@@ -0,0 +1,126 @@
+
+require(shorts)
+WorlChampionshipSplitTimes <-
read.csv2("~/chronojump/r-scripts/tests/shortsLibrary/WorlChampionshipSplitTimes.csv")
+
+results = matrix(nrow=length(WorlChampionshipSplitTimes[,1]), ncol = 16)
+colnames(results) = c("Vmax3P", "Tau3P"
+ , "Vmax3CorrectedP", "Tau3CorrectedP"
+ , "Vmax3CorrectedS", "Tau3CorrectedS"
+ , "Vmax4P", "Tau4P"
+ , "Vmax4CorrectedP", "Tau4CorrectedP"
+ , "Vmax4S", "Tau4S"
+ , "Vmax4CorrectedS", "Tau4CorrectedS"
+ , "Vmax5CorrectedS", "Tau5CorrectedS"
+)
+
+for(i in 1:length(WorlChampionshipSplitTimes[,1])){
+
+ splitTimes5 = data.frame(
+ position = c(10,20,30,40, 50),
+ time = c(WorlChampionshipSplitTimes[i,5], WorlChampionshipSplitTimes[i,6],
WorlChampionshipSplitTimes[i,7], WorlChampionshipSplitTimes[i,8], WorlChampionshipSplitTimes[i,9])
+ )
+
+ splitTimes4 = data.frame(
+ position = c(10,20,30,40),
+ time = c(WorlChampionshipSplitTimes[i,5], WorlChampionshipSplitTimes[i,6],
WorlChampionshipSplitTimes[i,7], WorlChampionshipSplitTimes[i,8])
+ )
+
+
+ # Padu's 3 split times model without correction
+ splitTimes3 = data.frame(
+ position = c(10,20,30),
+ time = c(WorlChampionshipSplitTimes[i,5], WorlChampionshipSplitTimes[i,6],
WorlChampionshipSplitTimes[i,7])
+ )
+
+ model = nls(position ~ Vmax*(time + (1/K)*exp(-K*time)) -Vmax/K, splitTimes3
+ , start = list(K = 0.81, Vmax = 10), control=nls.control(maxiter=1000, warnOnly=TRUE))
+ # print(paste("P --- Vmax:", summary(model)$parameters[2], "Tau:", 1/summary(model)$parameters[1]))
+ results[i, "Vmax3P"] = summary(model)$parameters[2]
+ results[i, "Tau3P"] = summary(model)$parameters[1]
+
+ #Shorts 3 split times model with correction (Padu's correction)
+ model = getModelWithOptimalTimeCorrection(splitTimes3)
+ results[i, "Vmax3CorrectedS"] = summary(model)$parameters[1]
+ results[i, "Tau3CorrectedS"] = summary(model)$parameters[2]
+
+ # Padu's 4 split times model without correction
+ model = nls(position ~ Vmax*(time + (1/K)*exp(-K*time)) -Vmax/K, splitTimes4
+ , start = list(K = 0.81, Vmax = 10), control=nls.control(maxiter=1000, warnOnly=TRUE))
+ # print(paste("P --- Vmax:", summary(model)$parameters[2], "Tau:", 1/summary(model)$parameters[1]))
+ results[i, "Vmax4P"] = summary(model)$parameters[2]
+ results[i, "Tau4P"] = summary(model)$parameters[1]
+
+ #Shorts 4 split times model without correction
+ model = with(
+ splitTimes4,
+ model_using_splits(position, time)
+ )
+ # print(paste("Shorts --- Vmax:", summary(model)$parameters[1], "Tau:", 1/summary(model)$parameters[2]))
+ results[i, "Vmax4S"] = summary(model)$parameters[1]
+ results[i, "Tau4S"] = summary(model)$parameters[2]
+
+ #Shorts 4 split times model with time correction
+ model = with(
+ splitTimes4,
+ model_using_splits_with_time_correction(position, time)
+ )
+ # print(paste("Shorts --- Vmax:", summary(model)$parameters[1], "Tau:", 1/summary(model)$parameters[2]))
+ results[i, "Vmax4CorrectedS"] = summary(model)$parameters[1]
+ results[i, "Tau4CorrectedS"] = summary(model)$parameters[2]
+
+ #Shorts 5 split times model with time and distance correction
+ model = with(
+ splitTimes5,
+ model_using_splits_with_time_correction(position, time)
+ )
+ # print(paste("Shorts --- Vmax:", summary(model)$parameters[1], "Tau:", 1/summary(model)$parameters[2]))
+ results[i, "Vmax5CorrectedS"] = summary(model)$parameters[1]
+ results[i, "Tau5CorrectedS"] = summary(model)$parameters[2]
+
+}
+
+getModelWithOptimalTimeCorrection <- function(split_times)
+{
+ # print("In getModelWithOptimalTimeCorrection()")
+ bestTimeCorrection = 0
+ currentTimeCorrection = bestTimeCorrection
+
+ model <- with(
+ split_times,
+ model_using_splits(position, time, time_correction = bestTimeCorrection)
+ )
+
+ # print("### Without correction ###")
+ # print(model)
+
+ minError = 1E6
+
+ #TODO: Use better algorithm for finding optimal correction
+ while(model$model_fit$RSE < minError){
+ minError = model$model_fit$RSE
+ # print(paste("New minError:", minError))
+ # print(paste("current RSE:", model$model_fit$RSE))
+ currentTimeCorrection = currentTimeCorrection + 0.001
+ # Simple model
+ model <- with(
+ split_times,
+ model_using_splits(position, time, time_correction = currentTimeCorrection)
+ )
+ # print(model$model_fit$RSE)
+ if (model$model_fit$RSE < minError){
+ bestTimeCorrection = currentTimeCorrection
+ }
+ }
+
+ model <- with(
+ split_times,
+ model_using_splits(position, time, time_correction = bestTimeCorrection)
+ )
+
+ # print("### With optimal correction ###")
+ # print(paste("Time correction:", bestTimeCorrection))
+ # print(model)
+
+ return(model)
+}
+print(results)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]