The audit()
function is deprecated, use explain
from the DALEX
package instead.
audit( object, data = NULL, y = NULL, predict.function = NULL, residual.function = NULL, label = NULL, predict_function = NULL, residual_function = NULL )
object | An object containing a model or object of class explainer (see |
---|---|
data | Data.frame or matrix - data that will be used by further validation functions. If not provided, will be extracted from the model. |
y | Response vector that will be used by further validation functions. Some functions may require an integer vector containing binary labels with values 0,1. If not provided, will be extracted from the model. |
predict.function | Function that takes two arguments: model and data. It should return a numeric vector with predictions. |
residual.function | Function that takes three arguments: model, data and response vector. It should return a numeric vector with model residuals for given data. If not provided, response residuals (\(y-\hat{y}\)) are calculated. |
label | Character - the name of the model. By default it's extracted from the 'class' attribute of the model. |
predict_function | Function that takes two arguments: model and data. It should return a numeric vector with predictions. |
residual_function | Function that takes three arguments: model, data and response vector. It should return a numeric vector with model residuals for given data. If not provided, response residuals (\(y-\hat{y}\)) are calculated. |
An object of class explainer
.
data(titanic_imputed, package = "DALEX") model_glm <- glm(survived ~ ., family = binomial, data = titanic_imputed) audit_glm <- audit(model_glm, data = titanic_imputed, y = titanic_imputed$survived)#> Preparation of a new explainer is initiated #> -> model label : lm ( default ) #> -> data : 2207 rows 8 cols #> -> target variable : 2207 values #> -> predict function : yhat.glm will be used ( default ) #> -> predicted values : No value for predict function target column. ( default ) #> -> model_info : package stats , ver. 4.1.1 , task classification ( default ) #> -> predicted values : numerical, min = 0.008128381 , mean = 0.3221568 , max = 0.9731431 #> -> residual function : difference between y and yhat ( default ) #> -> residuals : numerical, min = -0.9628583 , mean = -2.569729e-10 , max = 0.9663346 #> A new explainer has been created!p_fun <- function(model, data) { predict(model, data, response = "link") } audit_glm_newpred <- audit(model_glm, data = titanic_imputed, y = titanic_imputed$survived, predict.function = p_fun)#> Preparation of a new explainer is initiated #> -> model label : lm ( default ) #> -> data : 2207 rows 8 cols #> -> target variable : 2207 values #> -> predict function : predict.function #> -> predicted values : No value for predict function target column. ( default ) #> -> model_info : package stats , ver. 4.1.1 , task classification ( default ) #> -> predicted values : numerical, min = -4.804232 , mean = -0.9354308 , max = 3.590008 #> -> residual function : difference between y and yhat ( default ) #> -> residuals : numerical, min = -3.255166 , mean = 1.257588 , max = 4.804232 #> A new explainer has been created!#>#>#> Preparation of a new explainer is initiated #> -> model label : randomForest ( default ) #> -> data : 150 rows 5 cols extracted from the model #> -> target variable : not specified! ( WARNING ) #> -> predict function : yhat.randomForest will be used ( default ) #> -> predicted values : No value for predict function target column. ( default ) #> -> model_info : package randomForest , ver. 4.6.14 , task multiclass ( default ) #> -> model_info : Model info detected multiclass task but 'y' is a NULL . ( WARNING ) #> -> model_info : By deafult multiclass tasks supports only factor 'y' parameter. #> -> model_info : Consider changing to a factor vector with true class names. #> -> model_info : Otherwise I will not be able to calculate residuals or loss function. #> -> predicted values : predict function returns multiple columns: 3 ( default ) #> -> residual function : difference between 1 and probability of true class ( default ) #> A new explainer has been created!