|
a |
|
b/R/Testing_Comparison.R |
|
|
1 |
# Testing_Comparison.R |
|
|
2 |
require(data.table) |
|
|
3 |
require(Metrics) |
|
|
4 |
require(stringr) |
|
|
5 |
require(ggplot2) |
|
|
6 |
Metrics:: |
|
|
7 |
rsq <- function (x, y) {cor(x, y) ^ 2} |
|
|
8 |
|
|
|
9 |
all_full_evals <- list.files("Full_Model_Testing_Results/", full.names = T, pattern = "GDSC2") |
|
|
10 |
|
|
|
11 |
all_full_metrics <- data.table(data_used = NULL, training_type = NULL, length_of_testing_data = NULL, MSE = NULL, |
|
|
12 |
RMSE = NULL, MSLE = NULL, RSQ = NULL, Pearson = NULL) |
|
|
13 |
|
|
|
14 |
for (filename in all_full_evals) { |
|
|
15 |
cur_eval <- fread(filename) |
|
|
16 |
cur_data <- str_replace(strsplit(basename(filename), "GDSC2")[[1]][1], "-", "_") |
|
|
17 |
cur_results <- data.table(data_used = cur_data, |
|
|
18 |
training_type = "Full", |
|
|
19 |
length_of_testing_data = nrow(cur_eval), |
|
|
20 |
MSE = mse(cur_eval$actual_target, cur_eval$predicted_target), |
|
|
21 |
RMSE = rmse(cur_eval$actual_target, cur_eval$predicted_target), |
|
|
22 |
MSLE = msle(cur_eval$actual_target, cur_eval$predicted_target), |
|
|
23 |
RSQ = rsq(cur_eval$actual_target, cur_eval$predicted_target), |
|
|
24 |
Pearson = cor(cur_eval$actual_target, cur_eval$predicted_target, method = "pearson")) |
|
|
25 |
all_full_metrics <- rbind(all_full_metrics, cur_results) |
|
|
26 |
} |
|
|
27 |
|
|
|
28 |
all_full_metrics_long = melt.data.table(all_full_metrics[, c(1,2,4)], id.vars = c("data_used", "training_type"), variable.name = "Metric", value.name = "Loss") |
|
|
29 |
ggplot(data = all_full_metrics_long) + |
|
|
30 |
geom_bar(mapping = aes(x = reorder(data_used, -Loss), y = Loss, group = Metric, fill = Metric), position = "dodge", stat = "identity") + |
|
|
31 |
theme(axis.text.x = element_text(angle = -45, hjust = 0, size = 16)) |
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
all_bottleneck_evals <- list.files("BottleNeck_Model_Testing_Results/", full.names = T, pattern = "GDSC2") |
|
|
36 |
all_bottleneck_metrics <- data.table(data_used = NULL, training_type = NULL, length_of_testing_data = NULL, MSE = NULL, RMSE = NULL, MSLE = NULL, RSQ = NULL) |
|
|
37 |
|
|
|
38 |
for (filename in all_bottleneck_evals) { |
|
|
39 |
cur_eval <- fread(filename) |
|
|
40 |
cur_data <- str_replace(strsplit(basename(filename), "GDSC2")[[1]][1], "-", "_") |
|
|
41 |
cur_results <- data.table(data_used = cur_data, |
|
|
42 |
training_type = "BottleNeck", |
|
|
43 |
length_of_testing_data = nrow(cur_eval), |
|
|
44 |
MSE = mse(cur_eval$actual_target, cur_eval$predicted_target), |
|
|
45 |
RMSE = rmse(cur_eval$actual_target, cur_eval$predicted_target), |
|
|
46 |
MSLE = msle(cur_eval$actual_target, cur_eval$predicted_target), |
|
|
47 |
RSQ = rsq(cur_eval$actual_target, cur_eval$predicted_target)) |
|
|
48 |
all_bottleneck_metrics <- rbind(all_bottleneck_metrics, cur_results) |
|
|
49 |
} |
|
|
50 |
|
|
|
51 |
all_bottleneck_metrics_long = melt.data.table(all_bottleneck_metrics[, c(1,2,4)], id.vars = c("data_used", "training_type"), variable.name = "Metric", value.name = "Loss") |
|
|
52 |
|
|
|
53 |
# ggplot(data = all_bottleneck_metrics_long) + |
|
|
54 |
# geom_bar(mapping = aes(x = reorder(data_used, -Loss), y = Loss, group = Metric, fill = Metric), position = "dodge", stat = "identity") + |
|
|
55 |
# theme(axis.text.x = element_text(angle = -45, hjust = 0, size = 16)) |
|
|
56 |
|
|
|
57 |
|
|
|
58 |
all_tests <- rbind(all_full_metrics_long, all_bottleneck_metrics_long) |
|
|
59 |
ggplot(data = all_tests) + |
|
|
60 |
geom_bar(mapping = aes(x = reorder(data_used, -Loss), y = Loss, group = Metric), position = "dodge", stat = "identity") + |
|
|
61 |
theme(axis.text.x = element_text(angle = -90, hjust = 0, size = 16)) + |
|
|
62 |
facet_wrap(vars(training_type)) |