Commit f3ed33bc authored by Armin Rauschenberger's avatar Armin Rauschenberger
Browse files

automation

parent 9ff3c444
......@@ -3,7 +3,7 @@ Version: 0.0.0
Title: Elastic Net for Dichotomised Outcomes
Description: Implements lasso and ridge regression for dichotomised outcomes.
Depends: R (>= 3.0.0)
Imports: glmnet, palasso
Imports: glmnet
Suggests: knitr, testthat, RColorBrewer
Authors@R: person("Armin","Rauschenberger",email="a.rauschenberger@vumc.nl",role=c("aut","cre"))
VignetteBuilder: knitr
......
......@@ -100,7 +100,7 @@ cornet <- function(y,cutoff,X,alpha=1,npi=101,pi=NULL,nsigma=99,sigma=NULL,nfold
# fold identifiers
if(is.null(foldid)){
foldid <- palasso:::.folds(y=z,nfolds=nfolds)
foldid <- cornet:::.folds(y=z,nfolds=nfolds)
}
#--- model fitting ---
......@@ -453,7 +453,7 @@ predict.cornet <- function(object,newx,type="probability",...){
z <- 1*(y > cutoff)
if(is.null(foldid)){
fold <- palasso:::.folds(y=z,nfolds=nfolds)
fold <- cornet:::.folds(y=z,nfolds=nfolds)
} else {
fold <- foldid
}
......@@ -537,7 +537,7 @@ predict.cornet <- function(object,newx,type="probability",...){
.test <- function(y,cutoff,X,alpha=1,type.measure="deviance"){
z <- 1*(y > cutoff)
fold <- palasso:::.folds(y=z,nfolds=5)
fold <- cornet:::.folds(y=z,nfolds=5)
fold <- ifelse(fold==1,1,0)
fit <- cornet::cornet(y=y[fold==0],cutoff=cutoff,X=X[fold==0,],alpha=alpha)
......@@ -686,8 +686,6 @@ if(FALSE){
}
# Correct this function in the palasso package (search twice for "# typo").
.loss <- function (y,fit,family,type.measure,foldid=NULL){
if (!is.list(fit)) {
......@@ -793,6 +791,26 @@ if(FALSE){
return(loss)
}
# Import this function from the palasso package.
.folds <- function (y, nfolds, foldid = NULL){
if(!is.null(foldid)){
return(foldid)
}
#if (survival::is.Surv(y)){ # active in palasso
# y <- y[, "status"] # active in palasso
#} # active in palasso
if(all(y %in% c(0, 1))){
foldid <- rep(x = NA, times = length(y))
foldid[y == 0] <- sample(x = rep(x = seq_len(nfolds),
length.out = sum(y == 0)))
foldid[y == 1] <- sample(x = rep(x = seq_len(nfolds),
length.out = sum(y == 1)))
} else {
foldid <- sample(x = rep(x = seq_len(nfolds), length.out = length(y)))
}
return(foldid)
}
#--- Lost and found ------------------------------------------------------------
# calibrate (for cornet)
......
# DO NOT CHANGE the "init" and "install" sections below
# DO NOT CHANGE the "init" and "install" sections.
# Download script file from GitHub
init:
ps: |
$ErrorActionPreference = "Stop"
......@@ -13,39 +12,9 @@ install:
cache:
- C:\RLibrary
# Adapt as necessary starting from here
environment:
global:
USE_RTOOLS: true
R_VERSION: release
build_script:
- travis-tool.sh install_bioc_deps
- travis-tool.sh install_deps
test_script:
- travis-tool.sh run_tests
on_failure:
- 7z a failure.zip *.Rcheck\*
- appveyor PushArtifact failure.zip
artifacts:
- path: '*.Rcheck\**\*.log'
name: Logs
- path: '*.Rcheck\**\*.out'
name: Logs
- path: '*.Rcheck\**\*.fail'
name: Logs
- path: '*.Rcheck\**\*.Rout'
name: Logs
- path: '\*_*.tar.gz'
name: Bits
- path: '\*_*.zip'
name: Bits
......@@ -5,7 +5,7 @@ y <- list$y; X <- list$X
# penalised regression
cutoff <- 1
foldid <- palasso:::.folds(y=y>cutoff,nfolds=10)
foldid <- cornet:::.folds(y=y>cutoff,nfolds=10)
fit <- cornet::cornet(y=y,cutoff=cutoff,X=X,foldid=foldid)
net <- list()
net$gaussian <- glmnet::cv.glmnet(y=y,x=X,family="gaussian",foldid=foldid)
......
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