Learn R Programming

healthcareai (version 1.2.4)

calulcateAlternatePredictions: Recalculate predicted value based on alternate scenarios

Description

After getting alternate features via calculateSDChanges recalculate predicted values for each row in df.

Usage

calulcateAlternatePredictions(df, modelObj, type, outVectorAppend = NULL,
  removeCols = NULL)

Arguments

df

Data frame from which we'll calculate alternate predictions

modelObj

Object representing the model that is used for predictions

type

String representing which type of model is used

outVectorAppend

Optional list of values that we'll append predictions to. If not used, then a new vector is created.

removeCols

Optional list of column names to remove before calculating alternate predictions.

References

http://healthcareai-r.readthedocs.io

See Also

healthcareai

Examples

Run this code
# NOT RUN {
library(caret)
df <- data.frame(a=c(1,2,3,1),
                 b=c('m','f','m','m'),
                 c=c(0.7,1.4,2.4,2.0),
                 d=c(100,250,200,150))

# Get alternate feature scenarios
dfResult <- calculateSDChanges(df=df,
                               rowNum=2,
                               sizeOfSDPerturb = 0.5,
                               numColLeaveOut='d')

y <- c('y','n','y','n')

# Train model on original data frame
glmOb <- train(x = df,y = y,method = 'glm',family = 'binomial')

outList <- calulcateAlternatePredictions(df=dfResult,
                                         modelObj=glmOb,
                                         type='lasso')
outList
# }

Run the code above in your browser using DataLab