https://github.com/cran/live
Raw File
Tip revision: 8aed1f23c19d367e5b7d23427a5b7a167af51d2e authored by Mateusz Staniak on 15 January 2020, 05:30:17 UTC
version 1.5.13
Tip revision: 8aed1f2
add_predictions.Rd
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/explore.R
\name{add_predictions}
\alias{add_predictions}
\title{Add black box predictions to generated dataset}
\usage{
add_predictions(
  to_explain,
  black_box_model,
  data = NULL,
  predict_fun = predict,
  hyperparams = list(),
  ...
)
}
\arguments{
\item{to_explain}{List return by sample_locally function.}

\item{black_box_model}{String with mlr signature of a learner or a model with predict interface.}

\item{data}{Original data frame used to generate new dataset.
Need not be provided when a trained model is passed in
black_box_model argument.}

\item{predict_fun}{Either a "predict" function that returns a vector of the
same type as response or custom function that takes a model as a first argument,
and data used to calculate predictions as a second argument
and returns a vector of the same type as respone.
Will be used only if a model object was provided in the black_box argument.}

\item{hyperparams}{Optional list of (hyper)parameters to be passed to mlr::makeLearner.}

\item{...}{Additional parameters to be passed to predict function.}
}
\value{
list of class "live_explorer" consisting of
\item{data}{Dataset generated by sample_locally function with response variable.}
\item{target}{Name of the response variable.}
\item{model}{Black box model which is being explained.}
\item{explained_instance}{Instance that is being explained.}
\item{sampling_method}{Name of used sampling method}
\item{fixed_variables}{Names of variables which were not sampled}
\item{sdevations}{Standard deviations of numerical variables}
}
\description{
Add black box predictions to generated dataset
}
\examples{
\dontrun{
# Train a model inside add_predictions call.
local_exploration1 <- add_predictions(dataset_for_local_exploration,
                                      black_box_model = "regr.svm",
                                      data = wine)
# Pass trained model to the function.
svm_model <- svm(quality ~., data = wine)
local_exploration2 <- add_predictions(dataset_for_local_exploration,
                                      black_box_model = svm_model)
}

}
back to top