.onLoad <- function(libname, pkgname) {
packageStartupMessage("bonski.predict needs to call Python code")
if (reticulate::py_available(initialize = TRUE)) {
if (!reticulate::py_module_available("sktime")) {
packageStartupMessage("Installing Python dependencies...")
reticulate::py_install("sktime")
packageStartupMessage("Done!")
} else {
packageStartupMessage("Python dependencies already installed")
}
np <<- reticulate::import("numpy", convert = FALSE, delay_load = TRUE)
sklearn <<- reticulate::import("sklearn", convert = FALSE, delay_load = TRUE)
sktime <<- reticulate::import("sktime", convert = FALSE, delay_load = TRUE)
} else {
packageStartupMessage("Since Python is not available model fitting and classification WILL NOT work.")
}
}
.onUnload <- function (libpath) {
library.dynam.unload("bonski.predict", libpath)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.