knitr::opts_chunk$set(eval = TRUE)
options(width = 100)
library(KESER)
library(wordcloud)

Load the depression data into R.

dir <- "https://github.com/celehs/KESER/raw/master/rdata/"
data <- readRDS(url(paste0(dir, "depression.rds"), "rb"))
dict <- readRDS(url(paste0(dir, "dictionary.rds"), "rb"))

Feature Selection with Embeddings from Partners Healthcare

set.seed(123)
system.time(loc.fit.RPDR <- loc.feature.selection(
  data$X_full_lst[[1]], data$Y_full_lst[[1]],
  data$X_train_lst[[1]], data$Y_train_lst[[1]], 
  data$X_valid_lst[[1]], data$Y_valid_lst[[1]],
  alpha = 1, lambda_lst = NULL, up_rate = 10, 
  drop_rate = 0.5, cos_cut = 0.1, add.ridge = TRUE))
results.RPDR <- merge(loc.fit.RPDR$results, dict, all.x = TRUE)
results.RPDR
wordcloud(words = results.RPDR$description,
          freq = round(as.numeric(results.RPDR$coef) * 100),
          random.order = FALSE,
          colors = brewer.pal(8, "Dark2"),
          # scale = c(4, 0.2),
          rot.per = 0)

Feature Selection with Embeddings from Veteran Affairs (VA)

set.seed(123)
system.time(loc.fit.VA <- loc.feature.selection(
  data$X_full_lst[[2]], data$Y_full_lst[[2]],
  data$X_train_lst[[2]], data$Y_train_lst[[2]], 
  data$X_valid_lst[[2]], data$Y_valid_lst[[2]],
  alpha = 1, lambda_lst = NULL, up_rate = 10, 
  drop_rate = 0.5, cos_cut = 0.1, add.ridge = TRUE))
results.VA <- merge(loc.fit.VA$results, dict, all.x = TRUE)
results.VA
wordcloud(words = results.VA$description,
          freq = round(as.numeric(results.VA$coef) * 100),
          random.order = FALSE,
          colors = brewer.pal(8, "Dark2"),
          # scale = c(4, 0.2),
          rot.per = 0)
proc.time()


celehs/KESER documentation built on April 7, 2022, 9:35 a.m.