lossSharedTestKDSN: Kernel deep stacking network loss function with test set and...

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Computes the RMSE on a specified test set. The model is fitted one time and predicts the response in the test set. Tuning parameters are independent of the level.

Usage

1
2
3
4
lossSharedTestKDSN(parOpt, y, X, yTest, Xtest, seedW=NULL, lossFunc=devStandard,
varSelectShared=FALSE, varRanking=NULL, alphaShared=0, dropHiddenShared=FALSE,
seedDrop=NULL, standX=TRUE, standY=FALSE, 
namesParOpt=c("levels", "dim", "sigma", "lambdaRel"))

Arguments

parOpt

The numeric parameter vector of the tuning parameters. The length of the vector is required to be divisible with three without rest. The order of the parameters is (D, sigma, lambda) in one level. Each additional level is added as new elements, e.g. with two levels (D_1, sigma_1, lambda_1, D_2, sigma_2, lambda_2), etc.

y

Numeric response vector of the outcome. Should be formated as a one column matrix.

X

Numeric design matrix of the covariates. All factors have to be prior encoded.

yTest

Numeric response vector of the test set. Should be formated as a one column matrix.

Xtest

Numeric design matrix of the covariates of the test set. All factors have to be properly encoded, e. g. dummy encoding.

seedW

Seeds for the random Fourier transformation (integer vector). Each value corresponds to the seed of one level. The length must equal the number of levels of the kernel deep stacking network.

lossFunc

Specifies the used loss function for evaluation on the test observations. It must have arguments "preds" (predictions) and "ytest" (test observations). Default=devStandard is predictive deviance.

varSelectShared

Should unimportant variables be excluded? Default is that all available variables are used. (logical scalar). This setting is equal over all levels.

varRanking

Defines a variable ranking in increasing order. The first variable is least important and the last is the most important. (integer vector)

alphaShared

Weight parameter between lasso and ridge penalty (numeric vector). Default=0 corresponds to ridge penalty and 1 equals lasso. This setting is equal across all levels.

dropHiddenShared

Should dropout be applied on the random Fourier transformation? This setting is equal for all levels. Default is without dropout (logical vector).

seedDrop

Specifies the seed of the random dropouts in the calculation of random Fourier transformation per level. Default is random (integer vector).

standX

Should the design matrix be standardized by median and median absolute deviation? Default is TRUE.

standY

Should the response be standardized by median and median absolute deviation? Default is FALSE.

namesParOpt

Gives the names of the argument parOpt (character vector). It is used to encode the parameters into the correct structure suitable in fitting the kernel deep stacking network.

Details

namesParOpt: \ "level" corresponds to the number of levels of KDSN. \ "select" corresponds to the relative frequency of dropping unimportant variables according to the randomized dependence coefficient. \ "dim" corresponds to a dimension parameter of the random Fourier transformation. \ "sigma" corresponds to the precision parameter of the gaussian distribution to generate random weights. \ "dropProb" corresponds to probability of dropping out cells in the calculated random Fourier transformation matrix. \ "lambdaRel" corresponds to the regularization parameter of kernel ridge regression.

Value

Root mean squared error (numeric scalar). The fit is available as attribute.

Note

Should only be used by experienced users, who want to customize the model. It is called in the model selection process of the kernel deep stacking network, e. g. tuneMboLevelCvKDSN. The loss function can be adapted to specific data situations.

Author(s)

Thomas Welchowski welchow@imbie.meb.uni-bonn.de

References

Po-Seng Huang and Li Deng and Mark Hasegawa-Johnson and Xiaodong He, (2013), Random Features for kernel deep convex network, Proceedings IEEE International Conference on Acoustics, Speech, and Signal Processing (ICASSP)

Simon N. Wood, (2006), Generalized Additive Models: An Introduction with R, Taylor \& Francis Group LLC

See Also

lossApprox, lossCvKDSN, lossSharedCvKDSN, lossGCV

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
####################################
# Example with simple binary outcome

# Generate covariate matrix
sampleSize <- 100
X <- matrix(0, nrow=100, ncol=10)
for(j in 1:10) {
  set.seed (j)
  X [, j] <- rnorm(sampleSize)
}

# Generate response of binary problem with sum(X) > 0 -> 1 and 0 elsewhere
# with Gaussian noise
set.seed(-1)
error <- rnorm (100)
y <- ifelse((rowSums(X) + error) > 0, 1, 0)

# Draw a subset as test data
library(caret)
Indices <- createDataPartition(y=y, times = 1, p=0.8) [[1]]

# Calculate loss function with parameters (D=10, sigma=1, lambda=0)
# in one level
calcLoss <- lossSharedTestKDSN(parOpt=c(1, 10, 1, 0), y=y, X=X, 
yTest=y[-Indices], Xtest=X[-Indices, , drop=FALSE], seedW=0)
c(calcLoss)

kernDeepStackNet documentation built on May 2, 2019, 8:16 a.m.