Je fais une régression polynomial locale par la fonction localpoly.reg du package "NonpModelCheck".
Je veux faire une prédiction et validation croisée.
J'utilise le package "caret" mais comme cette fonction n'est pas présente dans les options "method" je dois la faire moi meme.
Code : Tout sélectionner
#k-folds cross validation
# Define training control
set.seed(123)
train.control <- trainControl(method = "cv", number = 10)
# Train the model
loc.reg<-list(type = "Regression",
library = "NonpModelCheck",
loop = NULL,
parameters=data.frame(c('degree.pol','kernel.type',
'bandwidth'),
class=c('numeric','character','character'),
label='parameter'),
##grid = function(x, y, len = NULL, search = "grid")
## data.frame(parameter = "none"),
loop = NULL,
fit = function(x, y, wts, param, lev, last, classProbs, ...) {
## mboost requires a data frame with predictors and response
dat <- if(is.data.frame(x)) x else as.data.frame(x)
dat$y <- y
mod <- localpoly.reg(xtr,ytr, degree.pol = 1,
kernel.type = "gaussian",bandwidth = "CV")
},
predict = function(modelFit, newdata, submodels = NULL) {
loc.mod1<-localpoly.reg(xtr,ytr, points=xte,degree.pol = 1, kernel.type = "gaussian",bandwidth = "CV")
y_pred<-loc.mod1$predicted
},
#prob = NULL,
#predictors = function(x, ...) {
# unique(as.vector(variable.names(x)))
#},
#tags = c("Ensemble Model", "Boosting", "Implicit Feature Selection"),
levels = NULL,
#sort = function(x) x
)
J'ai cette erreur
Code : Tout sélectionner
Error in list(type = "Regression", library = "NonpModelCheck", loop = NULL, :
argument 10 is empty
Je me suis basé sur le lienhttp://topepo.github.io/caret/using-your-own-model-in-train.html#illustrative-example-1-svms-with-laplacian-kernels pour faire cela mais je n'ai pas pu le faire exqctement. Pourriez vous m'aider svp?