getChanges: Get change in prediction for an updated feature.

Description Usage Arguments Value Author(s) See Also Examples

Description

This method calculates the changes in predictions, for a pre-determined Random Forest model and set of instances, resulting from updating the value(s) of a specified (vector of) feature(s). The method works with regression and classification models. In case of binary classification the predictions are calculated by predictBC() or predict.randomForest and represent the probabilities of being in a given class. If the model was obtained directly via the randomForest() function, the type of predictions calculated correspond to predict.randomForest(). However, if the model is a binary classification model and was obtained via post-processing the original model from randomForest(), using prepareForPredictBC(), the type of predictions calculated correspond to predictBC().

Usage

1
getChanges(features, dataT, object, value=NULL, type=NULL, mcls=NULL)

Arguments

features

a vector of the feature numbers/names to be updated

dataT

a data frame containing the variables in the model for all instances for which changes in predictions are desired

object

an object of the class randomForest

value

a vector of new feature values for the features provided in features N.B. If this is set to NULL, and the specified features are binary, the prediction changes reported are those associated with the only possible change in value for these features: from 1 to 0 or vice-versa.

type

the type of the predictions considered for classification models, by default it is set to type="prob" but can be set to type="votes".

mcls

main class that be set to "1" for binary classification. If NULL, the class name from the first record in dataT will be set as "1"

Value

A matrix n x m of prediction changes, n is the number of instances in dataT and m is the number of updated features.

Author(s)

Anna Palczewska annawojak@gmail.com and
Richard Marchese Robinson rmarcheserobinson@gmail.com

See Also

randomForest

Examples

1
2
3
4
5
6
7
8
library(randomForest)
data(ames)
ames_train<-ames[ames$Type=="Train",-c(1,3, ncol(ames))]
ames_train<-ames_train[1:100,]
rF_Model <- randomForest(x=ames_train[,-1],y=as.factor(as.character(ames_train[,1])),
  ntree=500,importance=TRUE, keep.inbag=TRUE,replace=FALSE) 
gc <- getChanges(c(1,166), ames_train, rF_Model)
change<-getChanges(c(1), ames_train[1, ], rF_Model, value = c(0.49))

rfFC documentation built on May 2, 2019, 5:18 p.m.

Related to getChanges in rfFC...