{"cells":[{"metadata":{"trusted":true},"cell_type":"code","source":"library(tidyverse)\n\nINPUT_DIR <- file.path(\"..\",\"input\")\nPROJECT <- list.files(INPUT_DIR)[1]\nINPUT_DIR <- file.path(INPUT_DIR, PROJECT)\nlist.files(INPUT_DIR)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"TRAIN_PATH <- file.path(INPUT_DIR, \"train.csv\")\n\ntrain <- read_csv(TRAIN_PATH, col_types=\"ciiiiiiiiiiic\")\nhead(train)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"cmatrix <- train %>%\n    select(-`StudyInstanceUID`,-`PatientID`) %>%\n    cor()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"corrs <- (cmatrix > -1 & cmatrix < -.1) | (cmatrix > .1 & cmatrix < 1) \nfiltered_corrs <- round(cmatrix, 2)\nfiltered_corrs[!corrs] <- \"\"\nfiltered_corrs","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train <-\ntrain %>%\n    mutate(Problems = rowSums(across(`ETT - Abnormal`:`Swan Ganz Catheter Present`)))\nhead(train)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"err_counts <- table(train$Problems)\nerr_counts","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"vals = length(0:max(train$Problems))\n\nggplot(train, aes(Problems, fill=\"any\")) + \n    geom_histogram(bins = vals) +\n    stat_bin(geom=\"text\", bins = vals, aes(label=..count.., vjust=-.25)) +\n    scale_x_continuous(n.breaks = vals) +\n    xlab(\"Number of Problems\") +\n    ylab(\"Record Count\") +\n    ggtitle(\"Problem Frequency\") +\n    theme_minimal() +\n    theme(legend.position=\"none\") ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"name":"ir","display_name":"R","language":"R"},"language_info":{"name":"R","codemirror_mode":"r","pygments_lexer":"r","mimetype":"text/x-r-source","file_extension":".r","version":"3.6.3"}},"nbformat":4,"nbformat_minor":4}