tensorflow / recommenders

TensorFlow Recommenders is a library for building recommender system models using TensorFlow.
Apache License 2.0
1.79k stars 270 forks source link

Explainability of TFRS-retrieval model #612

Open drtinumohan opened 1 year ago

drtinumohan commented 1 year ago

We are using TFRS-retrieval solution for our problem statement. Now we are looking for the model explainability part of TFRS-retrieval model. is there any way we can backtrack from the output and find what feature column leads to the predictions? For Instance, in a movie recommendation scenario, we more often predict cartoon movies to the users whose age are under 10. Here we can see the age of the user which cause the model to predict cartoon movies.

EdwardALockhart commented 1 year ago

Once you start to use fancy models like this you lose a lot of explainability - that is a standard trade off with the increased performance. Sounds like you are try to look for correlation and patterns in your input data. Just try and plot things up, how the most popular movies or genres (you can then count how many of each) change with a variable. You can suddenly see the problem… if you have a lot of variables or variables that interact to produce a pattern, good luck!

drtinumohan commented 1 year ago

Thank you, @EdwardALockhart , for sharing your insights on this topic and providing valuable input

We were able to find a solution by integrating shap with TFRS, despite the approach not being straightforward. we used the Amazon airline booking dataset, which includes training features such as USER_ID, USER_RESIDENCE, and CABIN_CLASS. Based on the dataset, Amazon suggests that users tend to prefer airlines based on their USER_RESIDENCE; for instance, someone living in the United States is more likely to choose United Airlines or American Airlines over other airlines.** After training, we leveraged shap to explain each recommendation made by TFRS, and the results were impressive.

For instance, when a user named Kjim from the United States was recommended flights by the TFRS engine, the top two recommendations were Asiana Airlines and United Airlines. To explain how the TFRS model made these recommendations, I used shap. Shap revealed that Asiana Airlines was recommended based on the user's preferences, while United Airlines was recommended due to the user's location in the United States.

Screenshot from 2023-04-08 14-44-57 Screenshot from 2023-04-08 14-43-30