#Activate python environment (only necessary
#on first opening of R session).
if (FALSE) {
ewsnet_init(envname = "EWSNET_env")
}
#A dummy dataset of a hedgerow bird population
#monitored over 50 years that needs to be tuned.
abundance_data <- data.frame(time = seq(1:50),
abundance = rnorm(50,mean = 20))
#Generate training data (this is random data as
#an example).
x <- matrix(nrow = 50, ncol = 10)
x <- sapply(1:dim(x)[2], function(i){
x[,i] <- rnorm(50,mean=20,sd=10)})
#Label each time series.
y <- sample(0:2,10,replace = TRUE)
#Finetune EWSNet.
if (FALSE) {
ewsnet_finetune(
x = x,
y = y,
scaling = TRUE,
envname = "EWSNET_env")
}
#Generate new EWSNet predictions.
if (FALSE) {
pred <- ewsnet_predict(
abundance_data$abundance,
scaling = TRUE,
ensemble = 15,
envname = "EWSNET_env")
}
Run the code above in your browser using DataLab