# Automated explanation - function results - simple attempt

I used to work as an analyst in a financial project where we had functions $$f$$ determining the price, and sometimes the inputs $$x$$ jumped in such a way to produce anomalous results. We had to report an explanation, and I wish to automate the process. It's not properly a question of AI, more of information science. The idea is that once, for a generic non-linear $$f$$, you can determine the ranking of relevance of $$x_i$$ in explaining the result, you can generate a full explanation by:

1. decompose $$f$$ as a composition of $$f_j$$, which are intermediate results with a definite meaning in the application domain (in this case, finance)
2. apply the algorithm using the $$f_j$$ instead of $$x_i$$, and then iterate it to explain the $$f_j$$ in terms of $$x_i$$

The relevance is quantified by the information gain of each variable. This will be explained for an application in ranking the $$x_i$$ directly. We assume to start on a uniform distribution on the $$x$$ domain, calculate the derived probability density function for $$f$$, and the information entropy of $$f$$. Then we fix the $$x_i$$ one at a time, for each calculate the new p.d.f. of $$f$$ conditioned on that $$x_i$$ and the (lower) information entropy of $$f$$. The information gain is $$IG(x_i)$$. Choose as the first conditioning the $$i$$ with the largest information gain, then condition of the remaining $$i$$ with a decreasing order of $$IG_i$$. So we could start for example , with $$(x_1,x_2,x_3)$$, to condition first on $$x_2$$, then on $$(x_2,x_3)$$, and then on $$(x_2,x_3,x_1)$$, getting the percentage contributions as: $$\frac{IG_i}{H_y}$$. The successive terms $$IG_i$$ add up always to the total entropy $$H_y$$, since conditioning on all variables gives a point and zero entropy.

Any opinion on how to improve this "automated function explanation" is welcome