View source: R/SklearnToJson.R
sklearnToJson | R Documentation |
Saves sklearn python model object to json in path
sklearnToJson(model, path)
model |
a fitted sklearn python model object |
path |
path to the saved model file |
nothing, saves the model to the path as json
## Not run:
sklearn <- reticulate::import("sklearn", convert = FALSE)
model <- sklearn$tree$DecisionTreeClassifier()
model$fit(sklearn$datasets$load_iris()$data, sklearn$datasets$load_iris()$target)
saveLoc <- file.path(tempdir(), "model.json")
sklearnToJson(model, saveLoc)
# the model.json is saved in the tempdir
dir(tempdir())
# clean up
unlink(saveLoc)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.