fitPlp | R Documentation |
Train various models using a default parameter grid search or user specified parameters
fitPlp(trainData, modelSettings, search = "grid", analysisId, analysisPath)
trainData |
An object of type |
modelSettings |
An object of class |
search |
The search strategy for the hyper-parameter selection (currently not used) |
analysisId |
The id of the analysis |
analysisPath |
The path of the analysis |
The user can define the machine learning model to train
An object of class plpModel
containing:
model |
The trained prediction model |
preprocessing |
The preprocessing required when applying the model |
prediction |
The cohort data.frame with the predicted risk column added |
modelDesign |
A list specifiying the modelDesign settings used to fit the model |
trainDetails |
The model meta data |
covariateImportance |
The covariate importance for the model |
# simulate data
data("simulationProfile")
plpData <- simulatePlpData(simulationProfile, n=1000)
# create study population, split into train/test and preprocess with default settings
population <- createStudyPopulation(plpData, outcomeId = 3)
data <- splitData(plpData, population, createDefaultSplitSetting())
data$Train$covariateData <- preprocessData(data$Train$covariateData)
saveLoc <- file.path(tempdir(), "fitPlp")
# fit a lasso logistic regression model using the training data
plpModel <- fitPlp(data$Train, modelSettings=setLassoLogisticRegression(seed=42),
analysisId=1, analysisPath=saveLoc)
# show evaluationSummary for model
evaluatePlp(plpModel$prediction)$evaluationSummary
# clean up
unlink(saveLoc, recursive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.