View source: R/FeatureImportance.R
pfi | R Documentation |
Calculate the permutation feature importance (pfi) for a PLP model.
pfi(
plpResult,
population,
plpData,
repeats = 1,
covariates = NULL,
cores = NULL,
log = NULL,
logthreshold = "INFO"
)
plpResult |
An object of type |
population |
The population created using createStudyPopulation() who will have their risks predicted |
plpData |
An object of type |
repeats |
The number of times to permute each covariate |
covariates |
A vector of covariates to calculate the pfi for. If NULL it uses all covariates included in the model. |
cores |
Number of cores to use when running this (it runs in parallel) |
log |
A location to save the log for running pfi |
logthreshold |
The log threshold (e.g., INFO, TRACE, ...) |
The function permutes the each covariate/features repeats
times and
calculates the mean AUC change caused by the permutation.
A dataframe with the covariateIds and the pfi (change in AUC caused by permuting the covariate) value
library(dplyr)
# simulate some data
data("simulationProfile")
plpData <- simulatePlpData(simulationProfile, n=1000)
# now fit a model
saveLoc <- file.path(tempdir(), "pfi")
plpResult <- runPlp(plpData, outcomeId = 3, saveDirectory = saveLoc)
population <- createStudyPopulation(plpData, outcomeId = 3)
pfi(plpResult, population, plpData, repeats = 1, cores = 1)
# compare to model coefficients
plpResult$model$covariateImportance %>% dplyr::filter(.data$covariateValue != 0)
# clean up
unlink(saveLoc, recursive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.