# On a linux machine
# Install Python
# sudo apt install python3-pip
# Install Python Miniconda for CPU computaion on a linux machine
# Download the file from https://docs.conda.io/en/latest/miniconda.html#linux-installers
# chmod +x Miniconda3-latest-Linux-x86_64.sh
# ./Miniconda3-latest-Linux-x86_64.sh
# conda create --name torch python=3.8
# conda activate torch
# conda install pytorch torchvision torchaudio cpuonly -c pytorch
# conda install -c conda-forge pycox
# export PATH="/home/username/.local/bin:$PATH"
# remotes::install_github("RaphaelS1/survivalmodels")
# install_pycox(method = "auto", conda = "auto", pip = TRUE, install_torch = TRUE )
# install_keras(method = "auto", conda = "auto", pip = TRUE, install_tensorflow = TRUE)
# use_condaenv(condaenv = "~/miniconda3/envs/torch", conda = "auto", required = FALSE)
# data(dataDIVAT2)
# The estimation of the hyperparameters
# tune.model<-tune.nn.time(times="times", failures="failures", data=dataDIVAT2[1:500,],
# cov.quanti=c("age"), cov.quali=c("hla", "retransplant", "ecd"),
# cv=3, n.nodes=c(1, 2), decay=0, batch.size=256L, epochs=1L)
# the estimated nodesize value
# tune.model$optimal
# tune.model$results
# The estimation of the training modelwith the corresponding lambda value
# model<-nn.time(times="times", failures="failures", data=dataDIVAT2,
# cov.quanti=c("age"), cov.quali=c("hla", "retransplant", "ecd"),
# n.nodes=tune.model$optimal$n.nodes, decay=0, batch.size=256L, epochs=1L)
# The resulted predicted survival of the first subject of the training sample
# plot(y=model$predictions[1,], x=model$times, xlab="Time (years)", ylab="Predicted survival",
# col=1, type="l", lty=1, lwd=2, ylim=c(0,1))
Run the code above in your browser using DataLab