{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"redocly_category":"Products","product_name":"Machine Learning","type":"markdown"},"seo":{"title":"Shap Analysis","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"shap-analysis","__idx":0},"children":["Shap Analysis"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This notebook shows ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://christophm.github.io/interpretable-ml-book/shap.html"},"children":["SHAP (SHapley Additive exPlanations)"]}," values to interpret the relative importance of features in the resulting predictions. Learn more about SHAP Analysis through this ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://blog.treasuredata.com/blog/2021/06/29/multi-touch-attribution-mta-with-shapley-values-tells-marketers-what-works-best/"},"children":["TD Blog Post"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Some sample visualizations are as follows:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image2023-3-7_14-44-12.166d8f68ff61e1f2f90a10047ea424a9857d4d3602a5615718cfaf02e6f84326.3cb60505.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image2023-3-7_14-46-9.e510e5121e3b893e866ada234b5744acc84dd5a611475a4728e90483e89780e3.3cb60505.png","alt":""},"children":[]},"Workflow Example"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Find a sample workflow here in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/treasure-boxes/blob/automl/machine-learning-box/automl/shapley.dig"},"children":["Treasure Boxes"]},"."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"+explain_predictions_by_shap:\n  ipynb>:\n    notebook: shapley\n    model_name: gluon_model         # model used for prediction\n    input_table: ml_test.gluon_test # test data used for prediction\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"parameters","__idx":1},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Parameter name"},"children":["Parameter name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Parameter on Console"},"children":["Parameter on Console"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Default Value"},"children":["Default Value"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["docker.task_name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Docker Task Mem"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Task memory size. Available values are 64g, 128g (default), 256g, 384g, or 512g depending on your contracted tiers"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["128g"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["model_name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Model Name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["prediction model name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["-"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["input_table"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Input Table"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["specify a TD table in dbname.table_name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["-"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["shared_model"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shared Model"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["specify a shared model UUID"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["None"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["sampling_threshold"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Sampling Threshold"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["threshold used for sampling. See the executed notebook in detail."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["10_000_000"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["hide_table_contents"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Hide Table Contents"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["suppress showing table contents"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["false"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["explain_threshold"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Explain Threshold"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["the number of rows to explain shapley values"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["200"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["interpret_samples"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Interpret Samples"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["the number of samples to build the surrogate model to interpret predictions"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["100"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["export_shap_values"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Export Shap Values"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["export shapley values as a TD table"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["None"]}]}]}]}]}]},"headings":[{"value":"Shap Analysis","id":"shap-analysis","depth":1},{"value":"Parameters","id":"parameters","depth":3}],"frontmatter":{"seo":{"title":"Shap Analysis"}},"lastModified":"2026-01-27T10:05:25.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/customer-data-platform/machine-learning/automl/notebook-solutions/shap-analysis","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}