# Illustrating the dimensionality reduction done by a classification or regression model

Tl;DR: You can predict something, but how do you explain the prediction?

Lets say the data is a classic regression/classification problem: several numerical columns, several nominal columns, and an event which we are trying to predict:

user1, age:18, wealth:20000, likes:tomatoes, isInBigCity:yes, hasClicked:yes
user2, age:25, wealth:24000, likes:carrots , isInBigCity:no , hasClicked:no
...


With the help of Random Forests, SVM, Logistic Regression, Deep Neural Network, or some other method we export a model that can output a probability of the event hasClicked:yes for a new user faced with the choice of clicking.

### Extracting the inner topology surfaced by a model

Now, those algorithm do some dimensionality reduction, reducing those inputs to a single probability. My question is: how would you extract what those models are doing and show the dimensionality reduction steps to a human? How would you illustrate the inner topology of the dataset with regards to the predicted class?

I am looking for either:

• Visualizations of what a model produced by Random Forests, SVM, Logistic Regression, Deep Neural Network is doing.

• Clusterers being extracted from regression/classification models (Surely a single decision tree can be viewed as a hierarchical clusterer)

• A model-specific way to project the input data in a space where the Euclidian distance of T-SNE makes sense.

• A way to learn a T-SNE-compatible distance out of a regression/classification model.

• Clustering methods that optimise the separation of one variable while not using it to cluster.

• Clusterers built out of regression/classification models

The goal is to extract some sort market segmentation based on the behaviour of users. And give a high level visualization of it. Something that would expose clearly the reasons why some users transform better than others.

• From the top of my head: - for Random Forest I would go for a proximity matrix, although that can be tricky for very large datasets (essentially for N observations you need a NxN matrix to represent all similarities) - for DNN just google "deep learning visualisations" for some approach to representing what the intermediate features are learning - for methods that assign feature relevance (like gbm or rf) try plotting the points in coordinates represented by the most relevant variables. if you're familiar with ggplot2 in R, i would definitely recommend that – kpb Aug 31 '15 at 11:03
• Thanks for the comment @kpb. RF with proximity matrix looks great! I'll look into detecting the most relevant features and working from there. – BenoitParis Sep 3 '15 at 19:49
• This is an extremely wide scope question. It would take a book to answer it. – EngrStudent Apr 22 '17 at 1:12
• More specifically, this book : christophm.github.io/interpretable-ml-book will help answering those questions. – lcrmorin Jan 18 '20 at 10:18
• @lcrmorin indeed! I forgot about that question from 4 years ago; and I confirm: this book lists lots of useful methods. – BenoitParis Jan 20 '20 at 10:56