fitHazard | R Documentation |
This function trains the model on casebase sampled data. It adds the loss as it changes over time, list of training data used as input and finally output training data to the cbnn prep.
fitHazard(
cbnnPrep,
epochs = 20000,
batchSize = 500,
earlyStoppingCallbacks = NULL,
valData = NULL
)
cbnnPrep |
(list) output from prepcbnnPrep function. |
epochs |
(numeric) number of epochs to learn through. |
batchSize |
(numeric) Number of samples to use for each batch. |
earlyStoppingCallbacks |
(list) expecting parameters for keras::callback_early_stopping as a list |
valData |
(list) A list of Lists. List[[1]][[1]] is the feature matrix, list[[1]][[2]] is the prediction,list[[2]] is the offset column. This is optional. |
(list) cbnnPrep: list from prepcbnnPrep passed in as argument,
resultOfFit: loss and metric over epochs,
xTrain: casebase sampled data that is used in learning phase,
yTrain: event feature used to assess what was learned in learning phase.
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)
fit<-fitHazard(cbnnPrep,epochs=1,batchSize=500)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.