applyEnsembleModel: Apply trained ensemble model on new data Apply a Patient...

Description Usage Arguments Examples

View source: R/Ensemble.R

Description

Apply trained ensemble model on new data Apply a Patient Level Prediction model on Patient Level Prediction Data and get the predicted risk in [0,1] for each person in the population. If the user inputs a population with an outcomeCount column then the function also returns the evaluation of the prediction (AUC, brier score, calibration)

Usage

1
2
3
4
5
6
7
applyEnsembleModel(
  population,
  dataList,
  ensembleModel,
  analysisId = NULL,
  calculatePerformance = T
)

Arguments

population

The population of people who you want to predict the risk for

dataList

The plpData list for the population

ensembleModel

The trained ensemble model returned by running runEnsembleModel

analysisId

The analysis ID, which is the ID of running ensemble model training.

calculatePerformance

Whether to also calculate the performance metrics [default TRUE]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 
# load the model and data
plpData <- loadPlpData("plpdata/")
results <- PatientLevelPrediction::runEnsembleModel(population,
                                                    dataList = list(plpData, plpData),
                                                    modelList = list(model, model),
                                                    testSplit = "person",
                                                    testFraction = 0.2,
                                                    nfold = 3,
                                                    splitSeed = 1000,
                                                    ensembleStrategy = "stacked")
# use the same population settings as the model:
populationSettings <- plpModel$populationSettings
populationSettings$plpData <- plpData
population <- do.call(createStudyPopulation, populationSettings)

# get the prediction, please make sure the ensemble strategy for training and apply is the same:
prediction <- applyEnsembleModel(population,
                                 dataList = list(plpData, plpData),
                                 ensembleModel = results,
                                 analysisId = NULL)$prediction

## End(Not run)

hxia/plp-git-demo documentation built on March 19, 2021, 1:54 a.m.