# BASIC XAI with DALEX — Part 7: Ceteris Paribus profiles

**R in ResponsibleML on Medium**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

#### BASIC XAI

### BASIC XAI with DALEX — Part 7: Ceteris Paribus profiles

Introduction to model exploration with code examples for R and Python.

Welcome to the “BASIC XAI with DALEX” series.

In this post, we present the **Ceteris Paribus profiles**, the model agnostic method, which is the one we can use for any type of model.

Previous parts of this series are available:

**BASIC XAI with DALEX — Part 1: Introduction**.**BASIC XAI with DALEX — Part 2: Permutation-based variable importance****.****BASIC XAI with DALEX — Part 3: Partial Dependence Profile****BASIC XAI with DALEX — Part 4: Break Down method****BASIC XAI with DALEX — Part 5: Shapley values****BASIC XAI with DALEX — Part 6: LIME method**

So, shall we start?

### First — What Ceteris Paribus deliver to us?

Ceteris Paribus is a Latin phrase meaning “other things held constant” or “all else unchanged”. Ceteris Paribus (CP) profiles are designed to show model response around a single point in the feature space. They show how the model response depends on changes in a single input variable, keeping all other variables unchanged. They work for any Machine Learning model and allow for model comparisons to better understand how a model is working.

### Second — Idea of Ceteris Paribus

Lef *f* denote a predictive model. Ceteris Paribus profiles for model* f*, variable* j*, and point *x₊* are defined as

where *x₊ *refers to a point in the feature space. Moreover *x ʲ|⁼ ᶻ* denotes a data point *x₊* with all coordinates equal to *x₊* except coordinate *j* equal to value *z*.

Look at the example for observation *x₊*, which takes the value 1998 for the year of construction, 88 for the surface, 2 for the number of floors, and 3 for the number of rooms. Variable *j* is a *construcion.year*, so it only takes different values and the other variables have values for observation *x₊*.

The Figure below shows the CP profile for a single observation described above. The purple dot is a value of prediction for *x₊, j *is feature* construction.year *and* z *takes value from the range 1920 to 2010.

### Third — let’s get a model in R and Python

Let’s write some code. We are still working on the DALEX *apartments* data. To calculate the Ceteris Paribus profile we use the *predict_profile()* function. We need the explainer object and the observation for which we want to calculate the explanation. Then using the *plot()* function we plot the CP profile.

In the figure below we have profiles for variables like *construction.year, surface, floor, and no.rooms*. Analyzing it we can read that if our property was built before 1935 or after 2000 its price could be higher. Moreover let’s look at the *surface* variable, if our apartment had a smaller surface its price would go up, but increasing the surface by every additional meter decreases it.

To evaluate how the prediction for selected observations behaves, we can draw several Ceteris Paribus profiles. See an example below. Each profile corresponds to one observation from the subset (the plot corresponds to 10 randomly selected observations). To get this plot, we must provide a data frame containing the selected number of observations as the value of the *new_observation* argument.

This is the last part of the “BASIC XAI with DALEX” series, thank you for the time you spent with me on this incredible XAI adventure.

*If you are interested in other posts about explainable, fair, and responsible ML, follow **#ResponsibleML** on Medium.*

*In order to see more R related content visit **https://www.r-bloggers.com*

BASIC XAI with DALEX — Part 7: Ceteris Paribus profiles was originally published in ResponsibleML on Medium, where people are continuing the conversation by highlighting and responding to this story.

**leave a comment**for the author, please follow the link and comment on their blog:

**R in ResponsibleML on Medium**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.