-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfusion_matrix.R
108 lines (75 loc) · 4.96 KB
/
confusion_matrix.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# setwd("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_wifi")
#
# # #All of Data
# file_list_test <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\all_data\\test\\dataset", full.names = TRUE)
# file_list_model <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\all_data\\model\\dataset", full.names = TRUE)
#Without Location
#
# file_list_test <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_location\\test\\dataset", full.names = TRUE)
# file_list_model <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_location\\model\\dataset", full.names = TRUE)
#WithoutWifi
#
# file_list_test <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_wifi\\test\\dataset", full.names = TRUE)
# file_list_model <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_wifi\\model\\dataset", full.names = TRUE)
#
#Without Activity
# setwd("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_activity")
# file_list_test <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_activity\\test\\dataset", full.names = TRUE)
# file_list_model <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_activity\\model\\dataset", full.names = TRUE)
#Without Run Apps
# setwd("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_apps")
# file_list_test <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_apps\\test\\dataset", full.names = TRUE)
# file_list_model <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_apps\\model\\dataset", full.names = TRUE)
#Without Run Battery
# setwd("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_battery")
# file_list_test <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_battery\\test\\dataset", full.names = TRUE)
# file_list_model <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_battery\\model\\dataset", full.names = TRUE)
#Without Call
# setwd("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_call")
# file_list_test <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_call\\test\\dataset", full.names = TRUE)
# file_list_model <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_call\\model\\dataset", full.names = TRUE)
#Without SMS
# setwd("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_sms")
# file_list_test <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_sms\\test\\dataset", full.names = TRUE)
# file_list_model <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_sms\\model\\dataset", full.names = TRUE)
#Without Activity and Call
# setwd("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_activity_call")
# file_list_test <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_activity_call\\test\\dataset", full.names = TRUE)
# file_list_model <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_activity_call\\model\\dataset", full.names = TRUE)
#Without Bluetooth and SMS
setwd("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_bluetooth_sms")
file_list_test <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_bluetooth_sms\\test\\dataset", full.names = TRUE)
file_list_model <- list.files("D:\\Dropbox\\thesis\\PROJECT\\data\\research-result\\without_bluetooth_sms\\model\\dataset", full.names = TRUE)
model_list <- file_list_model
test_list <- file_list_test
#[c(1,2,16,17,28,6,9,10,15,14)]
f_performance_testing <- function(data_model_path, data_test_path){
library(dplyr)
data_model <- read.csv(data_model_path, header=TRUE)
data_test <- read.csv(data_test_path, header=TRUE)
intersect <- semi_join(data_test,data_model)
except <- anti_join(data_test,data_model)
except_percentage <- (nrow(except)/nrow(data_test))*100
intersect_percentage <- (nrow(intersect)/nrow(data_test))*100
return(list("intersect"=intersect_percentage,"except"=except_percentage))
}
for (model in model_list){
for (test in test_list){
result <- f_performance_testing(model,test)
intersect_percentage <- round(result$intersect,3)
except_percentage <- round(result$except,3)
#final_output <- sprintf("%s/%s",intersect_percentage,except_percentage)
final_output <- sprintf("%s",intersect_percentage)
cat(print(paste(basename(model),basename(test), final_output,sep=",")),file="output.txt",append=TRUE,"\n")
print("Writing to file.......")
}
}
mydata <- read.csv("output.txt", header = FALSE)
head(mydata)
names(mydata) <- c("model","test","t")
out <- reshape(mydata, direction = "wide", idvar = "model", timevar = "test")
write.csv(out, file="output.csv")
new_df <- subset(mydata, mydata$test==mydata$model)
head(new_df)
#out <- reshape(new_df, direction = "wide", idvar = "model", timevar = "test")
write.csv(new_df, file="data_diagonal.csv")