prepCbnn | R Documentation |
This function attaches the required components to make survival outcomes possible from a binary classification network. Namely, it adds an offset term and passes the result through a Sigmoid activation function. This offset term is an offset in the statistical sense. As such, the network will add the offset term before passing through a sigmoid.
prepCbnn(
features,
nnInput,
nnOutput,
data,
offset = NA,
timeVar,
eventVar,
ratio = 100,
compRisk = FALSE,
kOptim = keras::optimizer_adam()
)
features |
(list) Input features to be used in model. |
nnInput |
(keras layer) Input layer for data to enter network. |
nnOutput |
(keras layer) Final keras layer of user designed network. Expected final layer is a single node. |
data |
(data.frame) Dataset to be used. can either be pre-casebase sampled with the sampleCaseBase function or the original dataset. |
offset |
(vector) Column of offset values generated from sampleCaseBase. |
timeVar |
(string) Survival time feature over which to eventually predict. |
eventVar |
(string) The event Feature in the data-set. |
ratio |
(numeric) Number of base-series samples per case-series samples. Default=100. |
compRisk |
(boolean) states if modeling competing risks or single event. |
kOptim |
("keras.optimizers.adam.Adam") Optimizer of choice from keras. Default set to optimizer_adam() |
(list) network: keras neural network model,
casebaseData: case-base sampled data,
offset: offset defined by case-base sampling,
timeVar: time variable (user defined),
eventVar: event variable (user defined),
features: feature of interest with user defined order.
library(cbnn)
library(casebase)
library(magrittr)
data<-casebase::ERSPC
data$ScrArm<-as.numeric(data$ScrArm)-1
eventVar<-"DeadOfPrCa"
timeVar<-"Follow.Up.Time"
features<-"ScrArm"
nnInput<-keras::layer_input(shape=length(features))
nnOutput<-nnInput %>% keras::layer_dense(units=1, use_bias = TRUE)
cbnnPrep<-prepCbnn(features, nnInput, nnOutput, data, offset=NA,timeVar,
eventVar, ratio=10, compRisk=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.