Skip to main content

A python alternative of the OHDSI PLP framework

Project description

P-PLP

P-PLP is a Python package for patient-level prediction on OMOP CDM data.

It helps you:

  • connect to PostgreSQL or DuckDB / Eunomia-style OMOP datasets
  • load target and outcome cohorts from Atlas SQL
  • generate labels for a time-at-risk window
  • build feature datasets
  • train and evaluate prediction models

Installation

Install from PyPI:

pip install p_plp

Install locally for development:

pip install -e .[dev]

Quick example

from p_plp.db import get_engine
from p_plp.cohorts import load_atlas_cohort_to_work_table, generate_labels_time_at_risk
from p_plp.feature_engineering import create_covariate_settings, run_feature_query
from p_plp.modeling import train_pipeline, evaluate

engine = get_engine(
    source_name="postgres",
    database_url="postgresql+psycopg2://user:password@localhost:5432/db",
    cdm_schema="cdm",
    work_schema="plp_work",
)

load_atlas_cohort_to_work_table(
    engine,
    sql=target_sql,
    cohort_definition_id=1,
    table_name="target_cohort",
)

load_atlas_cohort_to_work_table(
    engine,
    sql=outcome_sql,
    cohort_definition_id=2,
    table_name="outcome_cohort",
)

labels_df = generate_labels_time_at_risk(engine, risk_start_days=1, risk_end_days=365)

feature_config, base_config = create_covariate_settings(
    engine,
    useDemographicsAge=True,
    useDemographicsGender=True,
    useConditionEraAnyTimePrior=True,
)

dataset_df = run_feature_query(engine, feature_config, base_config)
model, X_test, y_test = train_pipeline(dataset_df, model_name="logreg")
metrics = evaluate(model, X_test, y_test)

More

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

p_plp_youri-0.0.2.tar.gz (391.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

p_plp_youri-0.0.2-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file p_plp_youri-0.0.2.tar.gz.

File metadata

  • Download URL: p_plp_youri-0.0.2.tar.gz
  • Upload date:
  • Size: 391.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for p_plp_youri-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8db3bbda2aecef15aa03fc02764006d51bff9ebce64ef01459f389c538a175a6
MD5 eb61bfdfcfa36dacb0aae93f873ec844
BLAKE2b-256 6b41e5d05ee39da84c8b28ce1dea2dfc97d8b6048f58392b325b9b8fb8e51063

See more details on using hashes here.

File details

Details for the file p_plp_youri-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: p_plp_youri-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for p_plp_youri-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d246939190d69831ddcbc3e69e4b4966014317d7d302c0a08652d2c716e8e96d
MD5 7dfe4858c219c4673e73c71cbb1ee0c2
BLAKE2b-256 f9c8b60b2fe579697c41f4f8061250799f958a8799f1ad1f3778a32cdfa02132

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page