ecpolley/SuperLearner — pull request #6 by lendle (2013-12-30 05:15:29+00:00)
Title: Add method.CC_LS and method.CC_nloglik

which compute optimal convex combinations of weights instead of normalizing non-neg weights for the squared error and negative binomial log likelihood. I think it would be good to make CC_LS and CC_nloglik the default for gaussian and binomial families, respectively.

The following demonstrates an improvement in the (training set) risk in an example from the docs.

``` bash
# binary outcome
set.seed(1)
N <- 200
X <- matrix(rnorm(N*10), N, 10)
X <- as.data.frame(X)
Y <- rbinom(N, 1, plogis(.2*X[, 1] + .1*X[, 2] - .2*X[, 3] +
.1*X[, 3]*X[, 4] - .2*abs(X[, 4])))

SL.library <- c("SL.glmnet", "SL.glm", "SL.knn", "SL.gam", "SL.mean")

set.seed(2)
# negative log binomial likelihood loss function
test.NNloglik <- SuperLearner(Y = Y, X = X, SL.library = SL.library,
verbose = FALSE, method = "method.NNloglik", family = binomial())

set.seed(2)
test.CC_nloglik <- SuperLearner(Y = Y, X = X, SL.library = SL.library,
verbose = FALSE, method = "method.CC_nloglik", family = binomial())

nloglik <- function(Y, p) mean (-Y * log(p) - (1-Y) * log(1-p))
```

```
> test.NNloglik$coef
SL.glmnet_All SL.glm_All SL.knn_All SL.gam_All SL.mean_All
0.000000000 0.000000000 0.004108256 0.671661310 0.324230434
> test.CC_nloglik$coef
SL.glmnet_All SL.glm_All SL.knn_All SL.gam_All SL.mean_All
1.882798e-16 1.796056e-15 2.108503e-01 7.891497e-01 0.000000e+00
```

```
> cat("NNloglik loss: ", nloglik(Y, predict(test.NNloglik)$pred), "\n")
NNloglik loss: 0.6027311
> cat("CC_loglik loss: ", nloglik(Y, predict(test.CC_nloglik)$pred), "\n")
CC_loglik loss: 0.5821341
```