Learn R Programming

PatientLevelPrediction (version 6.4.0)

sklearnFromJson: Loads sklearn python model from json

Description

Loads sklearn python model from json

Usage

sklearnFromJson(path)

Value

a sklearn python model object

Arguments

path

path to the model json file

Examples

Run this code
 # dontrun reason: requires python environment with sklearn 
if (FALSE) { 
plpData <- getEunomiaPlpData()
modelSettings <- setDecisionTree(maxDepth = list(3), minSamplesSplit = list(2),
                                  minSamplesLeaf = list(1), maxFeatures = list(100))
saveLocation <- file.path(tempdir(), "sklearnFromJson")
results <- runPlp(plpData, modelSettings = modelSettings, saveDirectory = saveLocation)
# view save model
dir(results$model$model, full.names = TRUE)
# load into a sklearn object
model <- sklearnFromJson(file.path(results$model$model, "model.json"))
# max depth is 3 as we set in beginning
model$max_depth
# clean up
unlink(saveLocation, recursive = TRUE)
}

Run the code above in your browser using DataLab