Implement DelphiBERT model and data preparation scripts for tabular time series analysis
- Added `model.py` containing the DelphiBERT architecture, including TabularEncoder and AutoDiscretization classes for handling tabular features. - Introduced `prepare_data.R` for merging disease and other data from UK Biobank, ensuring proper column selection and data integrity. - Created `prepare_data.py` to process UK Biobank data, including mapping field IDs, handling date variables, and preparing tabular features and event data for model training.
This commit is contained in:
26
prepare_data.R
Normal file
26
prepare_data.R
Normal file
@@ -0,0 +1,26 @@
|
||||
library(data.table)
|
||||
setDTthreads(40)
|
||||
library(readr)
|
||||
field_id <- read.csv("field_id.txt", header = FALSE)
|
||||
uid <- field_id$V1
|
||||
big_path <- "/mnt/storage/shared_data/UKBB/20230518-from-zhourong/HHdata_221103_0512.csv"
|
||||
header_dt <- fread(big_path, nrows = 0) # Read 0 rows => only column names
|
||||
all_names <- names(header_dt)
|
||||
keep_names <- intersect(all_names,uid)
|
||||
ukb_disease <- fread(big_path,
|
||||
select = keep_names,
|
||||
showProgress = TRUE)
|
||||
|
||||
field_id <- read.csv("field_id.txt", header = FALSE)
|
||||
uid <- field_id$V1
|
||||
big_path <- "/mnt/storage/shared_data/UKBB/20230518-from-zhourong/HH_data_220812_0512.csv"
|
||||
header_dt <- fread(big_path, nrows = 0) # Read 0 rows => only column names
|
||||
all_names <- names(header_dt)
|
||||
keep_names <- intersect(all_names,uid)
|
||||
ukb_others <- fread(big_path,
|
||||
select = keep_names,
|
||||
showProgress = TRUE)
|
||||
|
||||
# merge disease and other data by "eid"
|
||||
ukb_data <- merge(ukb_disease, ukb_others, by = "eid", all = TRUE)
|
||||
fwrite(ukb_data, "ukb_data.csv")
|
||||
Reference in New Issue
Block a user