Package 'pharmax.ml'

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

Help Index


Plot conformal calibration intervals

Description

Plot conformal calibration intervals

Usage

## S3 method for class 'pharmax_conformal_calibration'
plot(x, ...)

Arguments

x

A pharmax_conformal_calibration object.

...

Unused.

Value

A ggplot2 object.


Plot covariate screening results

Description

Plot covariate screening results

Usage

## S3 method for class 'pharmax_covariate'
plot(x, ...)

Arguments

x

A pharmax_covariate object.

...

Unused.

Value

A ggplot2 object.


Benchmark covariate screening on synthetic scenarios

Description

Benchmark covariate screening on synthetic scenarios

Usage

px_benchmark_covariate(
  scenarios = c("known_signal", "no_signal", "correlated", "missingness"),
  replicates = 5L,
  n = 120L,
  method = "auto",
  n_top = 5L,
  seed = 2026L
)

Arguments

scenarios

Scenario names passed to px_simulate_covariates().

replicates

Number of replicates per scenario.

n

Number of rows per replicate.

method

Screening method passed to px_covariate().

n_top

Number of top covariates to retain.

seed

Random seed.

Value

A pharmax_covariate_benchmark object.


Bootstrap prediction uncertainty

Description

Bootstrap prediction uncertainty

Usage

px_bootstrap_uq(truth, prediction, n_boot = 200L, alpha = 0.1, seed = 42L)

Arguments

truth

Observed outcomes.

prediction

Point predictions.

n_boot

Number of bootstrap replicates.

alpha

Miscoverage rate.

seed

Random seed.

Value

A pharmax_bootstrap_uq object.


Calibrate conformal interval coverage

Description

Calibrate conformal interval coverage

Usage

px_calibrate_conformal(truth, lower, upper, prediction = NULL, alpha = NULL)

Arguments

truth

Observed values.

lower

Lower interval bounds.

upper

Upper interval bounds.

prediction

Optional point predictions.

alpha

Optional target miscoverage rate.

Value

A pharmax_conformal_calibration object.


Conformal prediction intervals

Description

Conformal prediction intervals

Usage

px_conformal(
  truth,
  prediction,
  new_prediction,
  alpha = 0.1,
  method = c("split", "cross", "jackknife_plus")
)

Arguments

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. "split" is fully implemented; "cross" and "jackknife_plus" return conservative split-style intervals in this public proof slice.

Value

A tibble with predictions and conformal interval bounds.


ML covariate screening

Description

Screens covariates against pharmacometric parameter columns using R-native methods.

Usage

px_covariate(
  data,
  covariates = NULL,
  parameters = NULL,
  method = c("auto", "rf", "elastic_net", "lasso", "aalasso", "cor"),
  n_top = 10L,
  seed = 42L
)

Arguments

data

Data frame containing parameter and covariate columns.

covariates

Covariate column names. Auto-detects COV_ columns when NULL.

parameters

Parameter column names. Auto-detects ETA_, EBE_, or PARAM_.

method

One of "auto", "rf", "elastic_net", "lasso", "aalasso", or "cor".

n_top

Number of top covariates per parameter.

seed

Random seed.

Value

A pharmax_covariate object.


Assess ML data quality

Description

Assess ML data quality

Usage

px_data_quality(
  data,
  impute = c("none", "median", "knn", "rf"),
  outlier = c("none", "iqr", "isolation"),
  reduce = c("none", "pca"),
  cluster = FALSE
)

Arguments

data

Data frame.

impute

Imputation strategy: "none", "median", "knn", or "rf".

outlier

Outlier strategy: "none", "iqr", or "isolation".

reduce

Dimensionality reduction: "none" or "pca".

cluster

Whether to add a simple cluster summary.

Value

A list with cleaned data and quality summaries.


Ensemble predictions

Description

Ensemble predictions

Usage

px_ensemble(
  ...,
  weights = NULL,
  newdata = NULL,
  method = c("average", "weighted", "stacking")
)

Arguments

...

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: "average", "weighted", or "stacking".

Value

Numeric vector of ensemble predictions with a pharmax_ensemble class.


Explain a fitted model with permutation importance

Description

Explain a fitted model with permutation importance

Usage

px_explain(
  model,
  data,
  truth = NULL,
  metric = c("rmse"),
  method = c("permutation", "pdp", "ice"),
  seed = 42L
)

Arguments

model

Fitted model with a predict() method.

data

Data frame of predictors.

truth

Observed outcome.

metric

Loss metric, currently "rmse".

method

Explanation method: "permutation", "pdp", or "ice".

seed

Random seed.

Value

Tibble of feature importance values.


Create an ML decision-support report object

Description

Create an ML decision-support report object

Usage

px_ml_report(
  screen,
  quality = NULL,
  calibration = NULL,
  benchmark = NULL,
  context = list()
)

Arguments

screen

A pharmax_covariate object.

quality

Optional pharmax_data_quality object.

calibration

Optional pharmax_conformal_calibration object.

benchmark

Optional pharmax_covariate_benchmark object.

context

Optional named list describing the context of use.

Value

A pharmax_ml_report object.


Simulate synthetic covariate benchmark data

Description

Simulate synthetic covariate benchmark data

Usage

px_simulate_covariates(
  n = 120L,
  scenario = c("known_signal", "no_signal", "correlated", "missingness"),
  seed = 2026L,
  signal = 0.75,
  noise = 0.3
)

Arguments

n

Number of rows.

scenario

Scenario: "known_signal", "no_signal", "correlated", or "missingness".

seed

Random seed.

signal

Signal strength for known-signal scenarios.

noise

Residual noise standard deviation.

Value

A data frame with COV_ covariates and ETA_ parameters.