Learn R Programming

auditor (version 1.3.5)

score_cooksdistance: Score based on Cooks Distance

Description

Cook’s distance are used for estimate of the influence of an single observation.

Usage

score_cooksdistance(object, verbose = TRUE, ...)

scoreCooksDistance(object, verbose = TRUE)

Value

A vector of Cook's distances for each observation.

numeric vector

Arguments

object

An object of class explainer created with function explain from the DALEX package.

verbose

If TRUE progress is printed.

...

Other arguments dependent on the type of score.

Details

Cook’s distance is a tool for identifying observations that may negatively affect the model. They may be also used for indicating regions of the design space where it would be good to obtain more observations. Data points indicated by Cook’s distances are worth checking for validity.

Cook’s Distances are calculated by removing the i-th observation from the data and recalculating the model. It shows how much all the values in the model change when the i-th observation is removed.

Models of classes other than lm and glm the distances are computed directly from the definition, so this may take a while.

See Also

score

Examples

Run this code
dragons <- DALEX::dragons[1:100, ]

# fit a model
model_lm <- lm(life_length ~ ., data = dragons)

# create an explainer
lm_audit <- audit(model_lm, data = dragons, y = dragons$life_length)

# calculate score
score_cooksdistance(lm_audit)


Run the code above in your browser using DataLab