# How to check for “statistical significance” of categorical feature in black box models

Let's say we have a categorical feature $$X_i$$ and we have build a black-box classification model like xgboost with $$X_i$$ as one of many predictors. We'd like to ask a question: does $$X_i$$ affects the overall prediction and, if so, how much?

In particular $$X_i$$ could be:

• a dichotomous variable
• a n-level variable where we are interested in the potential difference between two particular levels

In white-box models like linear regression we have tests to obtain statistical significance. But can we obtain statistical-significance-alike with black box models? Does any tool from explainable artifficial intelligence field is applicable to that? Or would it be better to just perform standard t-test on the output probabilities predictions?

First, you have to encode the feature. Models only take numerical features.

Then assessing the solution:

• You can either see the feature importance of the model

• Or use an XAI tool that will help you to understand the predictions. I normally use SHAP (SHapley Additive exPlanations):is a game theoretic approach to explain the output of any machine learning model. It connects optimal credit allocation with local explanations using the classic Shapley values from game theory and their related extensions.

https://github.com/slundberg/shap

• "Most models only take numerical features." – Ben Reiniger Feb 6 at 13:31
• For my understanding a model only work with numerical features. There are several implementations that use their own encoding before starting to optimize right? – Carlos Mougan Feb 6 at 13:33
• Tree models are capable of dealing with categorical variables without encoding (externally or internally): datascience.stackexchange.com/a/52103/55122 – Ben Reiniger Feb 6 at 13:38