Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for monomial evaluation #71

Closed
moralapablo opened this issue Nov 19, 2024 · 0 comments · Fixed by #72
Closed

Add support for monomial evaluation #71

moralapablo opened this issue Nov 19, 2024 · 0 comments · Fixed by #72
Assignees
Labels
enhancement New feature or request

Comments

@moralapablo
Copy link
Member

Current implementation of eval_poly() provides the final value of the given polynomial. However, to compare with typical XAI methods that provide feature importance in a local manner, such as SHAP values for a given observation, it would be nice to be able to compute the value of each monomial in the polynomial for a given observation.

As an example, having the polynomial $3+ 2x_1 - x_2 +4x_1x_2$ evaluated on $x=(1,1)$, would be $3 + 2 - 1 + 4$, where each of those values is the contribution of each monomial evaluated on the given point $x$.

Output dimension discussion

Currently, eval_poly() receives poly$values as a matrix, where each column represents a polynomial (all with the same terms) and each row is a given monomial in all those polynomials. It also receives a newdata item that can be a matrix or a dataframe where the columns are the variables or features and the rows the observations or instances.

Then, the output of eval_poly is built as a matrix with polynomials as columns (matching the columns in poly$values notation) and observations as rows (matching the rows in newdata notation).

However, a function that can compute monomial values as suggested needs to have a 3D output, as it would need to keep the different polynomials and observations dimensions as before, but also the monomials dimension, given by the rows in poly$values. An array with 3 dimensions seems the best option, where the dimensions could be c(n_observations, n_monomials, n_polynomials), so for the polynomial k, element [ , ,k] will be a matrix with observations as rows and monomials as columns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant