Created
November 19, 2013 17:23
-
-
Save tomaskrehlik/7549003 to your computer and use it in GitHub Desktop.
A cusom function to use jordan recurrent neural network from RSNNS package with caret.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grid <- expand.grid(.size=5:10) | |
modelFunc <- function(data, parameter, levels, last, ...) | |
{ | |
library(RSNNS) | |
list(fit = jordan(data[,setdiff(names(data),".outcome")], data$.outcome, size = parameter$.size, initFuncParams = c(1,-1, 0.3, 1, 0.5))) | |
} | |
predFunc <- function(object, newdata) | |
{ | |
library(RSNNS) | |
predict(object$fit, newdata) | |
} | |
sortFunc <- function(x) {return(x)} | |
ctrl <- trainControl(custom = list( | |
parameters = grid, | |
model = modelFunc, | |
prediction = predFunc, | |
probability = NULL, | |
sort = sortFunc), | |
method = "timeslice", | |
horizon = 1, | |
initialWindow = tsl, | |
fixedWindow=TRUE, | |
savePredictions = TRUE) | |
customRpart <- train(outcome ~ ., data = b, method = "custom", trControl = ctrl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment