# Chapter 4 Prediction understanding

In this chapter we introduce two groups of explainers that can be used to boost our understanding of model predictions.

• Section 4.1 presents explainers that helps to identify outliers.
• Section 4.2 presents explainers for model predictions. Each prediction can be split into parts attributed to particular variables. Having found out which variables are important and whether the prediction is accurate, one can validate the model.

Explainers presented here are illustrated based on two models fitted to the apartments data.

library("DALEX")
apartments_lm_model <- lm(m2.price ~ construction.year + surface + floor +
no.rooms + district, data = apartments)
library("randomForest")
set.seed(59)
apartments_rf_model <- randomForest(m2.price ~ construction.year + surface + floor +
no.rooms + district, data = apartments)

First we need to prepare wrappers for these models. They are in explainer_lm and explainer_rf objects.

explainer_lm <- explain(apartments_lm_model,
data = apartmentsTest[,2:6], y = apartmentsTest$m2.price) explainer_rf <- explain(apartments_rf_model, data = apartmentsTest[,2:6], y = apartmentsTest$m2.price)