Skip to contents

Bridges extract_sparse_concept_matrix() to PatientLevelPrediction and DeepPatientLevelPrediction: the same matrix you would feed to glmnet or scikit-learn (and, through Python, omop-learn) becomes a plpData object that createStudyPopulation(), runPlp() and the DeepPLP models accept. Rows keep the parquet's order (rowId is the 1-based row position).

Usage

as_plp_data(
  sparse_result,
  con,
  target_id = 1L,
  outcome_id = 1L,
  days_to_event = 1,
  cohort_end_days = 0
)

Arguments

sparse_result

A result of extract_sparse_concept_matrix() that includes an outcome (y).

con

DuckDB connection holding observation_period and person (used for daysFromObsStart, daysToObsEnd, age and gender).

target_id

Cohort definition id recorded as targetId.

outcome_id

Outcome id recorded in outcomes.

days_to_event

Day (relative to index) at which a positive label is placed: a scalar, or one value per row. Binary labels carry no timing, so the default 1 puts events inside PLP's default risk window (day 1 to 365); pass real times if you have them.

cohort_end_days

Days from index to cohort end (scalar or per row; default 0).

Value

A plpData object (cohorts, outcomes, covariateData, timeRef, metaData).

Details

Covariate ids follow the OHDSI convention concept_id * 1000 + analysis_id, using FeatureExtraction's long-term analysis ids (condition 102, drug 302, procedure 502), so they coincide with natively extracted covariates when the window is 365 days. Rows with no observation period around their index date are dropped (PatientLevelPrediction requires one), with a warning.

This produces the non-temporal covariate layout (patient x covariate). Temporal sequence models (DeepPLP's temporal transformer) take FeatureExtraction::createTemporalSequenceCovariateSettings() through plp_database_details() instead.