fitHazard: fitHazard

View source: R/fitHazard.R

fitHazardR Documentation

fitHazard

Description

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.

Usage

fitHazard(
  cbnnPrep,
  epochs = 20000,
  batchSize = 500,
  earlyStoppingCallbacks = NULL,
  valData = NULL
)

Arguments

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.

Value

(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.

Examples

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)


Jesse-Islam/cbnn documentation built on Jan. 13, 2024, 3:48 a.m.