Skip to content

using LIME with caret and method="nnet" #38

Open
@sfd99

Description

@sfd99

Lime R-pkg is great!
Thanks to your suggestions,
the code now works fine.

2 quick Questions

Q1:
Is there a way to make the
plot_features(explanation[1:8, ])
display the plot cases (15,18,25,7) in the same order
as the cases in the test.set (7,15,18,25...) ?

reason: it's easier to present results to the end User
if the case numbers are in the same order
as in the test.set file...

Q2:
Would it be possible
to include inside/next to each color plot bar,
the actual value of a column ?
(ie: next to condition:
Petal.Length <= 1.6
you would display the actual value for Case 7: 1.4)

reason: avoids User having to consult the test.set file for each Case in plot .
The tested value is right there, in the plot... :-)

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Complete example code below :
inTrain <- createDataPartition(y=iris$Species, p=0.75, list=FALSE) # 75% for the train.set
train.set <- iris[inTrain,]
test.set <- iris[-inTrain,]

model <- train(Species ~ ., train.set, method='nnet', trace = FALSE, preProc = c("center", "scale"))
prediction <- predict(model, test.set[-5])
table(prediction, test.set$Species)
prediction <- predict(model, test.set[-5], type="prob")

now LIME!
Create an explainer object
explainer <- lime(train.set, model)

Explain new observation:
explanation <- explain(test.set[,-5], explainer, n_labels = 1, n_features = 2)
plot_features(explanation[1:8, ])

head(test.set)
Sepal.Length Sepal.Width Petal.Length
7 4.6 3.4 1.4
15 5.8 4.0 1.2
18 5.1 3.5 1.4
25 4.8 3.4 1.9
28 5.2 3.5 1.5
29 5.2 3.4 1.4

Thanks Thomas!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions