wrap4Explanation {ExplainPrediction} | R Documentation |
Wrap prediction model for explanations
Description
The function wraps given prediction model to be used with ExplainPrediction package.
Currently nnet
from nnet
package and models of class svm
from package e1071
are supported, but others can easily be added. Please, note that models from
CORElearn-package
can be used directly and need no wrapper.
If inclusion of other models into ExplainPrediction is desired, please, contact the author.
Usage
wrap4Explanation(model)
Arguments
model |
The model as returned by |
package.
Details
The function adds necessary components to the prediction model so that function explainVis
can generate explanations and their visualizations.
Currently, four components are added:
-
formula
, a formula specifying the dependent and independent variables used by the supplied model. -
model
, a name of the supplied model. -
noClasses
, a number of class values for classification problems and 0 for regression. -
class.lev
, for classification problem a vector of class value names.
If for a given model
the method predict
returns the class value probabilities
as matrix or in a list with component probabilities
, nothing else is needed, otherwise
the internal function getPredictions
has to be adequately modified.
Value
The function returns unchanged model
with the components described in Details.
Author(s)
Marko Robnik-Sikonja
See Also
Examples
## Not run:
# use iris data set, split it randomly into a training and testing set
trainIdxs <- sample(x=nrow(iris), size=0.7*nrow(iris), replace=FALSE)
testIdxs <- c(1:nrow(iris))[-trainIdxs]
# build a nnet model with certain parameters
require(nnet)
modelNN <- nnet(Species ~ ., iris[trainIdxs,], size=20)
# use wrapper
modelNNet <- wrap4Explanation(modelNN)
# generate model explanation and visualization
# turn on history in the visualization window to see all graphs
explainVis(modelNNet, iris[trainIdxs,], iris[testIdxs,], method="EXPLAIN",visLevel="both",
problemName="iris", fileType="none",
naMode="avg", explainType="WE", classValue=1)
## End(Not run)