View source: R/partialDependence.R
autoPDP | R Documentation |
Partial dependence plots (PDPs) help you to visualize the relationship between a subset of the features and the response while accounting for the average effect of the other predictors in the model. They are particularly effective with black box models like random forests, gradient boosting, etc.
autoPDP( train, trainedModel, target, feature, sample = 0.5, modelname, seed = 1991 )
train |
[data.frame | Required] training sample used to train ML model |
trainedModel |
[model object | Required] the object holding the machine learning model and the data |
target |
[character | Optional] target variable name. Specify target variable if model object is other than MLR or driveML |
feature |
[character | Optional] the feature name for which to compute the effects |
sample |
[numeric | Optional] percentage of sample to be considered for training set for faster computation. Default of 0.5 |
modelname |
[character | Optional] specify whcih model to be plotted |
seed |
[integer | Optional] random seed number. Default is 121 |
List object containing a plot for each feature listed.
FeatureEffects
plotPartialDependence
#' ## Example using DriveML model object mymodel = heart.model pdp_chol = autoPDP(heart, mymodel, feature = "chol", sample = 0.8, seed = 1234) # Type 1 DrvieML object hearML <- autoMLmodel(heart, target = "target_var", testSplit = 0.2, tuneIters = 10, tuneType = "random", models = "all", varImp = 20, liftGroup = 50, positive = 1, seed = 1991) cc = autoPDP(heart, hearML, feature = "chol", sample = 0.8, seed = 1234) # Type 2 other ML object library(randomForest) library(MASS) rf = randomForest(medv ~ ., data = Boston, ntree = 50) cc = autoPDP(Boston, rf,target = "medv", feature = "nox", sample = 1, seed = 121)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.