Description Usage Arguments Value Author(s) See Also Examples
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()
.
1 | getChanges(features, dataT, object, value=NULL, type=NULL, mcls=NULL)
|
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 |
value |
a vector of new feature values for the features provided in |
type |
the type of the predictions considered for classification models, by default it is set to |
mcls |
main class that be set to "1" for binary classification. If |
A matrix n x m
of prediction changes, n
is the number of instances in dataT
and m
is the number of updated features.
Anna Palczewska annawojak@gmail.com and
Richard Marchese Robinson rmarcheserobinson@gmail.com
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.