| Title: | R-Native Machine Learning Helpers for Pharmacometrics |
|---|---|
| Description: | R-native machine learning helpers for exploratory pharmacometric workflows. Includes covariate screening, conformal prediction intervals, explainability helpers, data quality checks, ensemble summaries, synthetic benchmarks, calibration summaries, and bounded evidence summaries. |
| Authors: | Malek Okour |
| Maintainer: | Malek Okour <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.0.9000 |
| Built: | 2026-05-27 11:00:54 UTC |
| Source: | https://github.com/pharmax-org/pharmax |
Plot conformal calibration intervals
## S3 method for class 'pharmax_conformal_calibration' plot(x, ...)## S3 method for class 'pharmax_conformal_calibration' plot(x, ...)
x |
A |
... |
Unused. |
A ggplot2 object.
Plot covariate screening results
## S3 method for class 'pharmax_covariate' plot(x, ...)## S3 method for class 'pharmax_covariate' plot(x, ...)
x |
A |
... |
Unused. |
A ggplot2 object.
Benchmark covariate screening on synthetic scenarios
px_benchmark_covariate( scenarios = c("known_signal", "no_signal", "correlated", "missingness"), replicates = 5L, n = 120L, method = "auto", n_top = 5L, seed = 2026L )px_benchmark_covariate( scenarios = c("known_signal", "no_signal", "correlated", "missingness"), replicates = 5L, n = 120L, method = "auto", n_top = 5L, seed = 2026L )
scenarios |
Scenario names passed to |
replicates |
Number of replicates per scenario. |
n |
Number of rows per replicate. |
method |
Screening method passed to |
n_top |
Number of top covariates to retain. |
seed |
Random seed. |
A pharmax_covariate_benchmark object.
Bootstrap prediction uncertainty
px_bootstrap_uq(truth, prediction, n_boot = 200L, alpha = 0.1, seed = 42L)px_bootstrap_uq(truth, prediction, n_boot = 200L, alpha = 0.1, seed = 42L)
truth |
Observed outcomes. |
prediction |
Point predictions. |
n_boot |
Number of bootstrap replicates. |
alpha |
Miscoverage rate. |
seed |
Random seed. |
A pharmax_bootstrap_uq object.
Calibrate conformal interval coverage
px_calibrate_conformal(truth, lower, upper, prediction = NULL, alpha = NULL)px_calibrate_conformal(truth, lower, upper, prediction = NULL, alpha = NULL)
truth |
Observed values. |
lower |
Lower interval bounds. |
upper |
Upper interval bounds. |
prediction |
Optional point predictions. |
alpha |
Optional target miscoverage rate. |
A pharmax_conformal_calibration object.
Conformal prediction intervals
px_conformal( truth, prediction, new_prediction, alpha = 0.1, method = c("split", "cross", "jackknife_plus") )px_conformal( truth, prediction, new_prediction, alpha = 0.1, method = c("split", "cross", "jackknife_plus") )
truth |
Observed values in the calibration set. |
prediction |
Predicted values in the calibration set. |
new_prediction |
Predicted values for new observations. |
alpha |
Miscoverage rate. |
method |
Conformal method. |
A tibble with predictions and conformal interval bounds.
Screens covariates against pharmacometric parameter columns using R-native methods.
px_covariate( data, covariates = NULL, parameters = NULL, method = c("auto", "rf", "elastic_net", "lasso", "aalasso", "cor"), n_top = 10L, seed = 42L )px_covariate( data, covariates = NULL, parameters = NULL, method = c("auto", "rf", "elastic_net", "lasso", "aalasso", "cor"), n_top = 10L, seed = 42L )
data |
Data frame containing parameter and covariate columns. |
covariates |
Covariate column names. Auto-detects |
parameters |
Parameter column names. Auto-detects |
method |
One of |
n_top |
Number of top covariates per parameter. |
seed |
Random seed. |
A pharmax_covariate object.
Assess ML data quality
px_data_quality( data, impute = c("none", "median", "knn", "rf"), outlier = c("none", "iqr", "isolation"), reduce = c("none", "pca"), cluster = FALSE )px_data_quality( data, impute = c("none", "median", "knn", "rf"), outlier = c("none", "iqr", "isolation"), reduce = c("none", "pca"), cluster = FALSE )
data |
Data frame. |
impute |
Imputation strategy: |
outlier |
Outlier strategy: |
reduce |
Dimensionality reduction: |
cluster |
Whether to add a simple cluster summary. |
A list with cleaned data and quality summaries.
Ensemble predictions
px_ensemble( ..., weights = NULL, newdata = NULL, method = c("average", "weighted", "stacking") )px_ensemble( ..., weights = NULL, newdata = NULL, method = c("average", "weighted", "stacking") )
... |
Numeric prediction vectors or a data frame of predictions. |
weights |
Optional numeric weights. |
newdata |
Optional data used when inputs are fitted models. |
method |
Ensemble method: |
Numeric vector of ensemble predictions with a pharmax_ensemble class.
Explain a fitted model with permutation importance
px_explain( model, data, truth = NULL, metric = c("rmse"), method = c("permutation", "pdp", "ice"), seed = 42L )px_explain( model, data, truth = NULL, metric = c("rmse"), method = c("permutation", "pdp", "ice"), seed = 42L )
model |
Fitted model with a |
data |
Data frame of predictors. |
truth |
Observed outcome. |
metric |
Loss metric, currently |
method |
Explanation method: |
seed |
Random seed. |
Tibble of feature importance values.
Create an ML decision-support report object
px_ml_report( screen, quality = NULL, calibration = NULL, benchmark = NULL, context = list() )px_ml_report( screen, quality = NULL, calibration = NULL, benchmark = NULL, context = list() )
screen |
A |
quality |
Optional |
calibration |
Optional |
benchmark |
Optional |
context |
Optional named list describing the context of use. |
A pharmax_ml_report object.
Simulate synthetic covariate benchmark data
px_simulate_covariates( n = 120L, scenario = c("known_signal", "no_signal", "correlated", "missingness"), seed = 2026L, signal = 0.75, noise = 0.3 )px_simulate_covariates( n = 120L, scenario = c("known_signal", "no_signal", "correlated", "missingness"), seed = 2026L, signal = 0.75, noise = 0.3 )
n |
Number of rows. |
scenario |
Scenario: |
seed |
Random seed. |
signal |
Signal strength for known-signal scenarios. |
noise |
Residual noise standard deviation. |
A data frame with COV_ covariates and ETA_ parameters.