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
)

Arguments

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

Value

List object containing a plot for each feature listed.

See also

Examples

# \donttest{ #' ## Example using DriveML model object mymodel = heart.model pdp_chol = autoPDP(heart, mymodel, feature = "chol", sample = 0.8, seed = 1234)
#> input model object is from DriveML
# Type one MLR package mod <- mlr::train(makeLearner("classif.ranger"), iris.task) cc = autoPDP(iris, mod, feature = c("Sepal.Length","Sepal.Width","Petal.Length", "Petal.Width"), sample = 1, seed = 121)
#> input model object is from MLR
# Type 2 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)
#> [19:10:12] WARNING: amalgamation/../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior. #> [19:10:12] WARNING: amalgamation/../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior. #> [19:10:13] WARNING: amalgamation/../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior. #> [19:10:13] WARNING: amalgamation/../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior. #> [19:10:13] WARNING: amalgamation/../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior. #> [19:10:13] WARNING: amalgamation/../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior. #> [19:10:13] WARNING: amalgamation/../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior. #> [19:10:14] WARNING: amalgamation/../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior. #> [19:10:14] WARNING: amalgamation/../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior. #> [19:10:14] WARNING: amalgamation/../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior. #> [19:10:14] WARNING: amalgamation/../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior.
cc = autoPDP(heart, hearML, feature = "chol", sample = 0.8, seed = 1234)
#> input model object is from DriveML
cc1 = autoPDP(heart, trainedModel,target = "target_var", feature = "chol", sample = 1, modelname = "logreg", seed = 121)
#> Error in paste0(class(trainedModel), collapse = "_"): object 'trainedModel' not found
# Type 3 other ML object library(randomForest)
#> Warning: package 'randomForest' was built under R version 4.0.4
#> randomForest 4.6-14
#> Type rfNews() to see new features/changes/bug fixes.
#> #> Attaching package: 'randomForest'
#> The following object is masked from 'package:ggplot2': #> #> margin
library(MASS) rf = randomForest(medv ~ ., data = Boston, ntree = 50) cc = autoPDP(Boston, rf,target = "medv", feature = "nox", sample = 1, seed = 121)
#> input model object is from other ML pacakges
# }