Hi everyone! 👋
In one of the recent projects I worked on, I developed a Model Interpretability dashboard to better understand how a machine learning model makes predictions and scores data. Among the various visualizations in the dashboard, one graph displayed the HyperSHAP values for a selected client, which could be chosen via a drop-down list. HyperSHAP values indicate how much each feature contributes to a prediction, with contributions being either positive or negative. For more information on Shapley values, refer to the references below. One challenge I faced was sorting the bars in this graph by their absolute values rather than their raw values.
In this article, @pathew and I will guide you through the steps to create a custom bar chart in SAS Visual Analytics. This chart will display HyperSHAP values (whether positive or negative) and order the bars based on their absolute values, using the data provided in the attached HyperSHAP_Values.csv file. The video below demonstrates the outcome we will be achieving by the end of the article:
To achieve this goal, we will leverage the power of SAS Graph Builder to create a custom graph object, which provides flexibility for visualizing your data. Let's get started!
To create a custom bar chart in SAS Graph Builder capable of sorting by a value different from what is displayed, we will employ a technique using two overlaid bar charts. Begin by accessing SAS Graph Builder through the Viya application menu under the Administration group, selecting Build Custom Graphs, and initiating a "New Custom Graph."
Drag and drop two Bar Chart elements from the Graph Elements pane onto the canvas.
To display only the desired values (positive or negative) and not absolute values, we will effectively "hide" the second bar chart. Achieve this by selecting the canvas to open the custom graph Options pane. Select "Bar Chart 2" from the drop-down list and set the "Transparency" to 100%.
1. In the Objects pane, accessible via the left pane, click on the Objects menu on the top-right corner and select Import custom graph.
2. Select the custom graph from the folder where you saved it and click Open. The graph is now ready to be used and is displayed together with the other objects.
Since this dataset contains the HyperSHAP values for five different customers, let's now add a Drop-down list to allow the user filter the bar chart based on the desired customer. We assign the Category role to the id variable, flag the Required option in the Options pane, and mark the custom bar chart in the Object Links section of the Actions pane.
Next, right-click on the graph and select absEstimate: Ascending (or Descending) for the Sort option.
If you followed all the steps above, you should now have obtained a report very similar to the one visible in the video attached at the beginning of the article!
This ends the detailed explanation on how to create a custom bar chart in SAS Graph Builder to sort the data by a value different from what is being displayed. The one above is just an example, and you can customize the same procedure based on your data sets and needs!
Of course, feel free to comment on this article or reach out to us via email (Mattia.Guglielmelli@sas.com and Paul.Thewalt@sas.com) for any feedback or questions. I hope you found this article helpful, see you next time! 😊
The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.