Commit e5da0d46 authored by GD's avatar GD

fix examples

parent 26f1de07
......@@ -99,5 +99,22 @@ stability.selection.heatmap(stab1)
tmp <- stability.selection(stab1, piThreshold=0.75, rhoError=10)
tmp
### "true" pertinent covariates
### "true" pertinent covariates vs selected ones
sample1$sel
tmp$selected.predictors
# effect of probability threshold
tmp <- sapply(seq(0.55,0.95,0.05), function(prob) {
return(length(stability.selection(stab1, piThreshold=prob, rhoError=10)$selected.predictors))
})
plot(seq(0.55,0.95,0.05), tmp)
# effect of restricting hyper-paramter grid
tmp <- sapply(seq(1,100,1), function(r) {
return(length(stability.selection(stab1, piThreshold=0.75, rhoError=r)$selected.predictors))
})
plot(seq(1,100,1), tmp)
# number of selected variables
length(sample1$sel)
tmp
......@@ -22,8 +22,9 @@ Ytest <- Y[index.test,]
### tuning the hyper-parameters
# /!\ on 10 cores
cv1 <- spls.adapt.tune(X=Xtrain, Y=Ytrain, lambda.l1.range=seq(0.05, 0.95, by=0.1), ncomp.range=1:5,
adapt=TRUE, return.grid=TRUE, ncores=10, nfolds=10)
cv1 <- spls.cv(X=Xtrain, Y=Ytrain, lambda.l1.range=seq(0.05, 0.95, by=0.1), ncomp.range=1:5,
adapt=TRUE, return.grid=TRUE, ncores=10, nfolds=10, nrun=1,
verbose=FALSE)
str(cv1)
### otpimal values
......@@ -31,8 +32,7 @@ lambda.l1 <- cv1$lambda.l1.opt
ncomp <- cv1$ncomp.opt
### fitting the model, and predicting new observations
model1 <- spls.adapt(Xtrain=Xtrain, Ytrain=Ytrain, Xtest=Xtest, lambda.l1=lambda.l1, ncomp=ncomp,
scale.Y=TRUE)
model1 <- spls(Xtrain=Xtrain, Ytrain=Ytrain, Xtest=Xtest, lambda.l1=lambda.l1, ncomp=ncomp)
str(model1)
### plotting the estimation versus real values for the non centered response
......@@ -55,3 +55,39 @@ points(-1000:1000,-1000:1000, type="l")
### selected variables
model1$A
######### stability selection procedure
## (/!\ using 8 cores)
stab1 <- spls.stab(X=Xtrain, Y=Ytrain,
lambda.l1.range=seq(0.05, 0.95, by=0.1), ncomp.range=1:5,
ncores=8, nresamp=100,
seed=NULL, verbose=TRUE)
str(stab1)
### heatmap of estimated probabilities
stability.selection.heatmap(stab1)
### selected covariates
tmp <- stability.selection(stab1, piThreshold=0.75, rhoError=10)
tmp
### "true" pertinent covariates vs selected ones
sample1$sel
tmp$selected.predictors
# effect of probability threshold
tmp <- sapply(seq(0.55,0.95,0.05), function(prob) {
return(length(stability.selection(stab1, piThreshold=prob, rhoError=10)$selected.predictors))
})
plot(seq(0.55,0.95,0.05), tmp)
# effect of restricting hyper-paramter grid
tmp <- sapply(seq(1,100,1), function(r) {
return(length(stability.selection(stab1, piThreshold=0.75, rhoError=r)$selected.predictors))
})
plot(seq(1,100,1), tmp)
# number of selected variables
length(sample1$sel)
tmp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment