In the featureContribution function (in the R package rfFC), what should we interpret if all the scores for all the features are negative? For example, if there were 7 features and after running the featureContribution function we got feature values as:

fc = c(-0.031544542, -0.064272583, -0.02307187, -0.000213402, -0.040743263, 
       -0.042137713, -0.080828973) 

Then what is the final interpretation? Is it something like all the features are not contributing to the prediction for this data point?

The github code for the package can be found here.

Please find a reproducible example to work with below

# # randomForest - For random forest model
library(randomForest) 
# # rfFc - For feature contribution
library(rfFC)

set.seed(294056)

# # Read input data
df = read.csv("https://raw.githubusercontent.com/kartheekpnsn/MyScripts/master/Files/input.csv")
# # Remove this column
df = df[-8]
# # Remove status column
df$Status = NULL

# # Master data 1-7 columns and Anomaly column
mydf = cbind(df[,1:7], df["Anomaly"])
rm(df)
# # Make Anomaly column as factor
mydf[,8] = as.factor(mydf[,8])
# # Change the name of Anomaly column to Status (not necessary)
colnames(mydf)[8] = "Status"
# # X: predictors
X <- mydf[, 1:(ncol(mydf) - 1)]
# # target: class
target <- mydf[,"Status"]

# # Build the model
rF_Model <- randomForest(x=X, y=as.factor(as.character(target)), ntree=500, importance=TRUE, keep.inbag=TRUE, replace=FALSE) 

li <- getLocalIncrements(rF_Model,X)
fc<-featureContributions(rF_Model, li, X)
fc = as.data.frame(fc)


# # Data where the fc score is all negative
output = cbind(fc[apply(fc, 1, function(x) all(x < 0)),], mydf[apply(fc, 1, function(x) all(x < 0)),])
print(fc[apply(fc, 1, function(x) all(x < 0)),])
print(output)
  • It would help if you could add some more context here, such as a reproducible example for people to work with. – gung Jun 8 '16 at 19:09
  • (To whom it may concern, note that how to interpret statistical output is generally on topic here.) – gung Jun 8 '16 at 19:10
  • Thanks @gung. I have added an example in the question (edited). – Kartheek Palepu Jun 9 '16 at 5:47
  • Please paste the reproducible example into your question. We want this thread to remain valuable even if the link goes dead. – gung Jun 9 '16 at 12:26

Unlike in the variable importance measures, feature contributions are computed separately for each instance/record and provide detailed information about relationships between variables and the predicted value: the extent and the kind of influence (positive/negative) of a given variable.

For more reference please see Interpreting random forest models using a feature contribution method

The paper can be also found in the describtion of the function from the linked package in the question post.

  • So accordingly should we be considering the absolute value instead of considering the signed value as the Feature Contribution score? – Kartheek Palepu Jun 8 '16 at 11:20

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.