Merge branch 'ml_pipeline' of https://repo.ijs.si/junoslukan/straw2analysis into ml_pipeline

ml_pipeline
Primoz 2023-04-19 15:56:52 +02:00
commit 2a8f1ee613
2 changed files with 54 additions and 1 deletions

4
.gitignore vendored
View File

@ -17,5 +17,7 @@ __pycache__/
/presentation/*scores.csv /presentation/*scores.csv
/presentation/Results.ods /presentation/Results.ods
.Rproj.user .Rproj.user
.Rhistory
/presentation/*.nb.html /presentation/*.nb.html
/presentation/ presentation/event_stressful_detection_half_loso.csv
presentation/event_stressful_detection_loso.csv

View File

@ -0,0 +1,51 @@
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)
# 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)