forked from nikiitin/RING-5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reduceSeeds.R
executable file
·50 lines (42 loc) · 1.73 KB
/
reduceSeeds.R
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
#!/usr/bin/Rscript
library(readr)
source("util.R")
arguments = commandArgs(trailingOnly = TRUE)
statsFile <- arguments[1]
configs <- arguments[2]
configs <- as.numeric(configs)
mean_algorithm <- arguments[3]
parsed_data <- read.table(statsFile, sep = " ", header=TRUE)
# Prepare the csv to be parsed by plotters
# Calculate mean
outputdf <- aggregate(parsed_data[(configs+1):ncol(parsed_data)], by=parsed_data[1:configs],FUN = mean)
outputdf["random_seed"] <- NULL
# Calculate sd
secondOdf <- aggregate(parsed_data[(configs+1):ncol(parsed_data)], by=parsed_data[1:configs],FUN = sd)
secondOdf["random_seed"] <- NULL
# Rename columns to differentiate between mean and sd
colnames(secondOdf)[(configs + 1):ncol(secondOdf)] <- paste("sd", colnames(secondOdf)[(configs + 1):ncol(secondOdf)], sep = "-")
# Merge both df
outputdf <- merge(x = outputdf, y = secondOdf, by = colnames(outputdf)[1:configs])
# Calculate mean if specified
# Note that this will add a new "benchmark" to the list
if (mean_algorithm != "None") {
if (mean_algorithm != "mean" &&
mean_algorithm != "geomean") {
warning("Mean was specified but with unexpected algorithm")
print("Availables algorithms: mean, geomean")
} else {
mean_df <- aggregate(
outputdf[(configs+1):ncol(outputdf)],
by = outputdf[1:configs - 1],
FUN = mean_algorithm)
mean_df["benchmark_name"] <- "Mean"
}
outputdf <- rbind(outputdf, mean_df)
}
# Prepare the csv to be parsed by plotters
# Create configuration names
outputdf["confName"] <- mixStringCols(1, configs, outputdf)
outputdf["confKey"] <- mixStringCols(1, configs - 1, outputdf)
# Write everything onto csv file
write.table(outputdf, statsFile, sep=" ", row.names = F)