From 5b9a1dba1a115bef47e4053538c7be107b081eee Mon Sep 17 00:00:00 2001 From: junos Date: Wed, 1 Mar 2023 13:37:10 +0100 Subject: [PATCH 1/4] Revert "Ignore presentation." This reverts commit ec7cd09a096aacc74537a4621b887adf72c8429c. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 57ce24b..4202a67 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,3 @@ __pycache__/ /presentation/Results.ods .Rproj.user /presentation/*.nb.html -/presentation/ From d0005518842766e97d45c6a1c9629e929e1b55af Mon Sep 17 00:00:00 2001 From: junos Date: Tue, 18 Apr 2023 14:57:59 +0200 Subject: [PATCH 2/4] Ignore only some files in presentation. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 4202a67..6f3bfb3 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,7 @@ __pycache__/ /presentation/*scores.csv /presentation/Results.ods .Rproj.user +.Rhistory /presentation/*.nb.html +presentation/event_stressful_detection_half_loso.csv +presentation/event_stressful_detection_loso.csv From d092e17e332c4a82c05cf4cd16aa83613f5dfb6f Mon Sep 17 00:00:00 2001 From: junos Date: Tue, 18 Apr 2023 15:34:06 +0200 Subject: [PATCH 3/4] Explore saved categories. --- presentation/ApplicationCategories.R | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 presentation/ApplicationCategories.R diff --git a/presentation/ApplicationCategories.R b/presentation/ApplicationCategories.R new file mode 100644 index 0000000..4834f0b --- /dev/null +++ b/presentation/ApplicationCategories.R @@ -0,0 +1,33 @@ +library(conflicted) +library(yaml) +library(RPostgreSQL) +library(tidyverse) +conflicts_prefer(dplyr::filter, + dplyr::lag) +library(magrittr) + +# read the password from file +credentials <- yaml.load_file("../rapids/credentials.yaml") +pw <- credentials$PSQL_STRAW$password + +#load the PostgreSQL driver +drv <- RPostgres::Postgres() + +# creates a connection to the postgres database +# note that "con" will be used later in each connection to the database +con <- RPostgres::dbConnect(drv, dbname = "staw", + host = "eol.ijs.si", port = 5432, + user = "staw_db", password = pw) + +rm(pw, credentials) # removes the password + +# check for the bluetooth table, an example +dbExistsTable(con, "app_categories") + +df_app_categories <- tbl(con, "app_categories") %>% + collect() + +head(df_app_categories) +table(df_app_categories$play_store_genre) + +dbDisconnect(con) From 0b16aa6fe4996b34f617361f87c257cbf510ff45 Mon Sep 17 00:00:00 2001 From: junos Date: Tue, 18 Apr 2023 15:49:33 +0200 Subject: [PATCH 4/4] Clean up categories. --- presentation/ApplicationCategories.R | 32 ++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/presentation/ApplicationCategories.R b/presentation/ApplicationCategories.R index 4834f0b..f229ac5 100644 --- a/presentation/ApplicationCategories.R +++ b/presentation/ApplicationCategories.R @@ -2,32 +2,50 @@ library(conflicted) library(yaml) library(RPostgreSQL) library(tidyverse) -conflicts_prefer(dplyr::filter, - dplyr::lag) +conflicts_prefer( + dplyr::filter, + dplyr::lag +) library(magrittr) # read the password from file credentials <- yaml.load_file("../rapids/credentials.yaml") pw <- credentials$PSQL_STRAW$password -#load the PostgreSQL driver +# load the PostgreSQL driver drv <- RPostgres::Postgres() # creates a connection to the postgres database # note that "con" will be used later in each connection to the database -con <- RPostgres::dbConnect(drv, dbname = "staw", - host = "eol.ijs.si", port = 5432, - user = "staw_db", password = pw) +con <- RPostgres::dbConnect(drv, + dbname = "staw", + host = "eol.ijs.si", port = 5432, + user = "staw_db", password = pw +) rm(pw, credentials) # removes the password # check for the bluetooth table, an example dbExistsTable(con, "app_categories") -df_app_categories <- tbl(con, "app_categories") %>% +df_app_categories <- tbl(con, "app_categories") %>% collect() head(df_app_categories) table(df_app_categories$play_store_genre) +# Correct some mistakes +df_app_categories %<>% mutate( + play_store_genre = { + function(x) { + case_when( + x == "Education,Education" ~ "Education", + x == "EducationEducation" ~ "Education", + x == "not_found" ~ "System", + .default = x + ) + } + }(play_store_genre) +) + dbDisconnect(con)