Home
%3CLINGO-SUB%20id%3D%22lingo-sub-870819%22%20slang%3D%22en-US%22%3EHow%20to%20make%20machine%20learning%20models%20interpretable%3A%20A%20seminar%20series%20at%20UC%20Berkeley%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-870819%22%20slang%3D%22en-US%22%3E%3CP%20style%3D%22margin%3A%200px%3B%20text-align%3A%20justify%3B%20color%3A%20%23333333%3B%20text-transform%3A%20none%3B%20line-height%3A%201.7142%3B%20text-indent%3A%200px%3B%20letter-spacing%3A%20normal%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20text-decoration%3A%20none%3B%20word-spacing%3A%200px%3B%20white-space%3A%20normal%3B%20box-sizing%3A%20border-box%3B%20orphans%3A%202%3B%20-webkit-text-stroke-width%3A%200px%3B%22%3EOn%20September%209th%2C%2010th%20and%2011th%2C%202019%2C%20we%20organized%20a%20few%20seminars%20at%20the%20University%20of%20California%2C%20Berkeley%20around%20the%20topic%20of%20Ethics%20in%20AI.%20Specifically%2C%20we%20shared%20a%20few%20insights%20and%20practical%20demos%20on%20how%20to%20make%20machine%20learning%20models%20interpretable%20and%20accessible%20with%20%3CA%20style%3D%22background-color%3A%20transparent%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23146cac%3B%20text-decoration%3A%20underline%3B%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmachine-learning%2F%3FWT.mc_id%3Dtechcommunity-article-lazzeri%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Machine%20Learning%3C%2FA%3E.%20In%20the%20next%20few%20paragraphs%2C%20we%20summarize%20the%20most%20important%20aspects%20presented%20during%20our%20seminars%3A%3C%2FP%3E%0A%3COL%20style%3D%22text-align%3A%20justify%3B%20color%3A%20%23333333%3B%20text-transform%3A%20none%3B%20text-indent%3A%200px%3B%20letter-spacing%3A%20normal%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20text-decoration%3A%20none%3B%20margin-top%3A%200px%3B%20margin-bottom%3A%2012px%3B%20word-spacing%3A%200px%3B%20white-space%3A%20normal%3B%20box-sizing%3A%20border-box%3B%20orphans%3A%202%3B%20-webkit-text-stroke-width%3A%200px%3B%22%3E%0A%3CLI%20style%3D%22box-sizing%3A%20border-box%3B%20font-family%3A%20%26amp%3Bquot%3B%22%3EHow%20to%20interpret%20your%20model%3C%2FLI%3E%0A%3CLI%20style%3D%22box-sizing%3A%20border-box%3B%20font-family%3A%20%26amp%3Bquot%3B%22%3EInterpretability%20during%20training%3C%2FLI%3E%0A%3CLI%20style%3D%22box-sizing%3A%20border-box%3B%20font-family%3A%20%26amp%3Bquot%3B%22%3EInterpretability%20at%20inferencing%20time%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20style%3D%22text-align%3A%20justify%3B%22%20id%3D%22toc-hId-1626315109%22%20id%3D%22toc-hId-1626315109%22%3E1.%26nbsp%3B%20How%20to%20interpret%20your%20model%3C%2FH3%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EWhen%20it%20comes%20to%20predictive%20modeling%2C%20you%20have%20to%20make%20a%20trade-off%3A%20do%20you%20just%20want%20to%20know%20what%20is%20predicted%3F%20For%20example%2C%20the%20probability%20that%20a%20customer%20will%20churn%20or%20how%20effective%20some%20drug%20will%20be%20for%20a%20patient.%20Or%20do%20you%20want%20to%20know%20why%20the%20prediction%20was%20made%20and%20possibly%20pay%20for%20the%20interpretability%20with%20a%20drop%20in%20predictive%20performance%3F%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EIn%20this%20section%20we%20briefly%20explain%20how%20you%20can%20explain%20why%20your%20model%20made%20the%20predictions%20it%20did%20with%20the%20various%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmachine-learning%2Fservice%2Fmachine-learning-interpretability-explainability%3FWT.mc_id%3Dtechcommunity-article-lazzeri%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Einterpretability%20packages%20of%20the%20Azure%20Machine%20Learning%20Python%20SDK%3C%2FA%3E.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EDuring%20the%20training%20phase%20of%20the%20development%20cycle%2C%20model%20designers%20and%20evaluators%20can%20use%20interpretability%20output%20of%20a%20model%20to%20verify%20hypotheses%20and%20build%20trust%20with%20stakeholders.%20They%20also%20use%20the%20insights%20into%20the%20model%20for%20debugging%2C%20validating%20model%20behavior%20matches%20their%20objectives%2C%20and%20to%20check%20for%20bias.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EIn%20machine%20learning%2C%20features%20are%20the%20data%20fields%20used%20to%20predict%20a%20target%20data%20point.%20For%20example%2C%20to%20predict%20credit%20risk%2C%20data%20fields%20for%20age%2C%20account%20size%2C%20and%20account%20age%20might%20be%20used.%20In%20this%20case%2C%20age%2C%20account%20size%2C%20and%20account%20age%20are%20features.%20Feature%20importance%20tells%20you%20how%20each%20data%20field%20affected%20the%20model%E2%80%99s%20predictions.%20For%20example%2C%20age%20may%20be%20heavily%20used%20in%20the%20prediction%20while%20account%20size%20and%20age%20don%E2%80%99t%20affect%20the%20prediction%20accuracy%20significantly.%20This%20process%20allows%20data%20scientists%20to%20explain%20resulting%20predictions%2C%20so%20that%20stakeholders%20have%20visibility%20into%20what%20data%20points%20are%20most%20important%20in%20the%20model.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EUsing%20these%20tools%2C%20you%20can%20explain%20machine%20learning%20models%20globally%20on%20all%20data%2C%20or%20locally%20on%20a%20specific%20data%20point%20using%20the%20state-of-art%20technologies%20in%20an%20easy-to-use%20and%20scalable%20fashion.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EThe%20interpretability%20classes%20are%20made%20available%20through%20multiple%20SDK%20packages.%20Learn%20how%20to%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpython%2Fapi%2Foverview%2Fazure%2Fml%2Finstall%3Fview%3Dazure-ml-py%3FWT.mc_id%3Dtechcommunity-article-lazzeri%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Einstall%20SDK%20packages%20for%20Azure%20Machine%20Learning%3C%2FA%3E.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%20style%3D%22text-align%3A%20justify%3B%22%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CP%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpython%2Fapi%2Fazureml-explain-model%2Fazureml.explain.model%3Fview%3Dazure-ml-py%3FWT.mc_id%3Dtechcommunity-article-lazzeri%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eazureml.explain.model%3C%2FA%3E%3C%2FSTRONG%3E%2C%20the%20main%20package%2C%20containing%20functionalities%20supported%20by%20Microsoft.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CP%3E%3CSTRONG%3Eazureml.contrib.explain.model%3C%2FSTRONG%3E%2C%20preview%2C%20and%20experimental%20functionalities%20that%20you%20can%20try.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CP%3E%3CSTRONG%3Eazureml.train.automl.automlexplainer%3C%2FSTRONG%3E%26nbsp%3Bpackage%20for%20interpreting%20automated%20machine%20learning%20models.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EYou%20can%20apply%20the%20interpretability%20classes%20and%20methods%20to%20understand%20the%20model%E2%80%99s%20global%20behavior%20or%20specific%20predictions.%20The%20former%20is%20called%20global%20explanation%20and%20the%20latter%20is%20called%20local%20explanation.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EThe%20methods%20can%20be%20also%20categorized%20based%20on%20whether%20the%20method%20is%20model%20agnostic%20or%20model%20specific.%20Some%20methods%20target%20certain%20type%20of%20models.%20For%20example%2C%20SHAP%E2%80%99s%20tree%20explainer%20only%20applies%20to%20tree-based%20models.%20Some%20methods%20treat%20the%20model%20as%20a%20black%20box%2C%20such%20as%20mimic%20explainer%20or%20SHAP%E2%80%99s%20kernel%20explainer.%20The%26nbsp%3Bexplain%26nbsp%3Bpackage%20leverages%20these%20different%20approaches%20based%20on%20data%20sets%2C%20model%20types%2C%20and%20use%20cases.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EThe%20output%20is%20a%20set%20of%20information%20on%20how%20a%20given%20model%20makes%20its%20prediction%2C%20such%20as%3A%3C%2FP%3E%0A%3CUL%20style%3D%22text-align%3A%20justify%3B%22%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CSTRONG%3EGlobal%2Flocal%20relative%20feature%20importance%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CSTRONG%3EGlobal%2Flocal%20feature%20and%20prediction%20relationship%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EThere%20are%20two%20sets%20of%20explainers%3A%20Direct%20Explainers%20and%20Meta%20Explainers%20in%20the%20SDK.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSTRONG%3EDirect%20explainers%3C%2FSTRONG%3E%20come%20from%20integrated%20libraries.%20The%20SDK%20wraps%20all%20the%20explainers%20so%20that%20they%20expose%20a%20common%20API%20and%20output%20format.%20If%20you%20are%20more%20comfortable%20directly%20using%20these%20explainers%2C%20you%20can%20directly%20invoke%20them%20instead%20of%20using%20the%20common%20API%20and%20output%20format.%20The%20following%20table%20lists%20the%20direct%20explainers%20available%20in%20the%20SDK%3A%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSTRONG%3EMeta%20explainers%3C%2FSTRONG%3E%26nbsp%3Bautomatically%20select%20a%20suitable%20direct%20explainer%20and%20generate%20the%20best%20explanation%20info%20based%20on%20the%20given%20model%20and%20data%20sets.%20The%20meta%20explainers%20leverage%20all%20the%20libraries%20(SHAP%2C%20LIME%2C%20Mimic%2C%20etc.)%20that%20we%20have%20integrated%20or%20developed.%20The%20following%20are%20the%20meta%20explainers%20available%20in%20the%20SDK%3A%3C%2FP%3E%0A%3CUL%20style%3D%22text-align%3A%20justify%3B%22%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CSTRONG%3ETabular%20Explainer%3C%2FSTRONG%3E%3A%20Used%20with%20tabular%20datasets.%3C%2FLI%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CSTRONG%3EText%20Explainer%3C%2FSTRONG%3E%3A%20Used%20with%20text%20datasets.%3C%2FLI%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CSTRONG%3EImage%20Explainer%3C%2FSTRONG%3E%3A%20Used%20with%20image%20datasets.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20style%3D%22text-align%3A%20justify%3B%22%20id%3D%22toc-hId--925841852%22%20id%3D%22toc-hId--925841852%22%3E2.%20Interpretability%20during%20training%3C%2FH3%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3ETo%20initialize%20an%20explainer%20object%2C%20you%20need%20to%20pass%20your%20model%20and%20some%20training%20data%20to%20the%20explainer's%20constructor.%20You%20can%20also%20optionally%20pass%20in%20feature%20names%20and%20output%20class%20names%20(if%20doing%20classification)%20which%20will%20be%20used%20to%20make%20your%20explanations%20and%20visualizations%20more%20informative.%20Here%20is%20how%20to%20instantiate%20an%20explainer%20object%20using%20TabularExplainer%2C%20MimicExplainer%2C%20and%20PFIExplainer%20locally.%20TabularExplainer%20is%20calling%20one%20of%20the%20three%20SHAP%20explainers%20underneath%20(TreeExplainer%2C%20DeepExplainer%2C%20or%20KernelExplainer)%2C%20and%20is%20automatically%20selecting%20the%20most%20appropriate%20one%20for%20your%20use%20case.%20You%20can%20however%2C%20call%20each%20of%20its%20three%20underlying%20explainers%20directly%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Efrom%20azureml.explain.model.tabular_explainer%20import%20TabularExplainer%0A%23%20%22features%22%20and%20%22classes%22%20fields%20are%20optional%0Aexplainer%20%3D%20TabularExplainer(model%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20x_train%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20features%3Dbreast_cancer_data.feature_names%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20classes%3Dclasses)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSTRONG%3EGlobal%20visualizations%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EThe%20following%20plots%20provide%20a%20global%20view%20of%20the%20trained%20model%20along%20with%20its%20predictions%20and%20explanations.%3C%2FP%3E%0A%3CTABLE%20width%3D%22100%25%22%3E%0A%3CTHEAD%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EPlot%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EDescription%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTHEAD%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3EData%20Exploration%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EAn%20overview%20of%20the%20dataset%20along%20with%20prediction%20values.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3EGlobal%20Importance%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EShows%20the%20top%20K%20(configurable%20K)%20important%20features%20globally.%20This%20chart%20is%20useful%20for%20understanding%20the%20global%20behavior%20of%20the%20underlying%20model.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3EExplanation%20Exploration%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EDemonstrates%20how%20a%20feature%20is%20responsible%20for%20making%20a%20change%20in%20model%E2%80%99s%20prediction%20values%20(or%20probability%20of%20prediction%20values).%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3ESummary%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EUses%20a%20signed%20local%20feature%20importance%20values%20across%20all%20data%20points%20to%20show%20the%20distribution%20of%20the%20impact%20each%20feature%20has%20on%20the%20prediction%20value.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F133167iCA2EFC4FA87A26B0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image1.png%22%20title%3D%22image1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSTRONG%3ELocal%20visualizations%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EYou%20can%20click%20on%20any%20individual%20data%20point%20at%20any%20time%20of%20the%20preceding%20plots%20to%20load%20the%20local%20feature%20importance%20plot%20for%20the%20given%20data%20point.%3C%2FP%3E%0A%3CTABLE%20width%3D%22100%25%22%3E%0A%3CTHEAD%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EPlot%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EDescription%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTHEAD%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3ELocal%20Importance%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EShows%20the%20top%20K%20(configurable%20K)%20important%20features%20globally.%20This%20chart%20is%20useful%20for%20understanding%20the%20local%20behavior%20of%20the%20underlying%20model%20on%20a%20specific%20data%20point.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3EPerturbation%20Exploration%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EAllows%20you%20to%20change%20feature%20values%20of%20the%20selected%20data%20point%20and%20observe%20how%20those%20changes%20will%20affect%20prediction%20value.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3EIndividual%20Conditional%20Expectation%20(ICE)%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EAllows%20you%20to%20change%20a%20feature%20value%20from%20a%20minimum%20value%20to%20a%20maximum%20value%20to%20see%20how%20the%20data%20point's%20prediction%20changes%20when%20a%20feature%20changes.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F133168i333864BB678BDEF0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image2.png%22%20title%3D%22image2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20style%3D%22text-align%3A%20justify%3B%22%20id%3D%22toc-hId-816968483%22%20id%3D%22toc-hId-816968483%22%3E3.%20Interpretability%20at%20inferencing%20time%3C%2FH3%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3EThe%20explainer%20can%20be%20deployed%20along%20with%20the%20original%20model%20and%20can%20be%20used%20at%20scoring%20time%20to%20provide%20the%20local%20explanation%20information.%20We%20also%20offer%20lighter-weight%20scoring%20explainers%20to%20make%20interpretability%20at%20inferencing%20time%20more%20performant.%20The%20process%20of%20deploying%20a%20lighter-weight%20scoring%20explainer%20is%20similar%20to%20deploying%20a%20model%20and%20includes%20the%20following%20steps%3A%3C%2FP%3E%0A%3CUL%20style%3D%22text-align%3A%20justify%3B%22%3E%0A%3CLI%3ECreate%20an%20explanation%20object%20(e.g.%2C%20using%20TabularExplainer)%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Efrom%20azureml.contrib.explain.model.tabular_explainer%20import%20TabularExplainer%0A%20%0Aexplainer%20%3D%20TabularExplainer(model%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20initialization_examples%3Dx_train%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20features%3Ddataset_feature_names%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20classes%3Ddataset_classes%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20transformations%3Dtransformations)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%20style%3D%22text-align%3A%20justify%3B%22%3E%0A%3CLI%3ECreate%20a%20scoring%20explainer%20using%20the%20explanation%20object%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Efrom%20azureml.contrib.explain.model.scoring.scoring_explainer%20import%20KernelScoringExplainer%2C%20save%0A%20%0A%23%20create%20a%20lightweight%20explainer%20at%20scoring%20time%0Ascoring_explainer%20%3D%20KernelScoringExplainer(explainer)%0A%20%0A%23%20pickle%20scoring%20explainer%0A%23%20pickle%20scoring%20explainer%20locally%0AOUTPUT_DIR%20%3D%20'my_directory'%0Asave(scoring_explainer%2C%20directory%3DOUTPUT_DIR%2C%20exist_ok%3DTrue)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%20style%3D%22text-align%3A%20justify%3B%22%3E%0A%3CLI%3EConfigure%20and%20register%20an%20image%20that%20uses%20the%20scoring%20explainer%20model%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3E%23%20register%20explainer%20model%20using%20the%20path%20from%20ScoringExplainer.save%20-%20could%20be%20done%20on%20remote%20compute%0A%23%20scoring_explainer.pkl%20is%20the%20filename%20on%20disk%2C%20while%20my_scoring_explainer.pkl%20will%20be%20the%20filename%20in%20cloud%20storage%0Arun.upload_file('my_scoring_explainer.pkl'%2C%20os.path.join(OUTPUT_DIR%2C%20'scoring_explainer.pkl'))%0A%20%0Ascoring_explainer_model%20%3D%20run.register_model(model_name%3D'my_scoring_explainer'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20model_path%3D'my_scoring_explainer.pkl')%0A%0Aprint(scoring_explainer_model.name%2C%20scoring_explainer_model.id%2C%20scoring_explainer_model.version%2C%20sep%20%3D%20'%5Ct')%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3ETo%20see%20the%20full%20tutorial%20we%20presented%20at%20UC%20Berkeley%2C%20see%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmachine-learning%2Fservice%2Fmachine-learning-interpretability-explainability%3FWT.mc_id%3Dtechcommunity-article-lazzeri%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EModel%20interpretability%20with%20Azure%20Machine%20Learning%3C%2FA%3E.%20To%20see%20a%20collection%20of%20Jupyter%20notebooks%20that%20demonstrate%20the%20instructions%20above%20for%20different%20data%20science%20scenarios%2C%20see%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FMachineLearningNotebooks%2Ftree%2Fmaster%2Fhow-to-use-azureml%2Fexplain-modelhttps%3A%2Fgithub.com%2FAzure%2FMachineLearningNotebooks%2Ftree%2Fmaster%2Fhow-to-use-azureml%2Fexplain-model%3FWT.mc_id%3Dtechcommunity-article-lazzeri%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Machine%20Learning%20Interpretability%20sample%20notebooks%3C%2FA%3E.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20left%3B%22%3ETo%20learn%20more%2C%20you%20can%20also%20read%20the%20following%20articles%20and%20notebooks%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%20style%3D%22text-align%3A%20left%3B%20font-weight%3A%20400%3B%22%3EAzure%20Machine%20Learning%20Notebooks%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FAzureMLServiceGithub%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eaka.ms%2FAzureMLServiceGithub%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22text-align%3A%20left%3B%20font-weight%3A%20400%3B%22%3EAzure%20Machine%20Learning%20Service%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FAzureMLservice%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eaka.ms%2FAzureMLservice%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22text-align%3A%20left%3B%20font-weight%3A%20400%3B%22%3EGet%20started%20with%20Azure%20ML%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FGetStartedAzureML%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eaka.ms%2FGetStartedAzureML%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22text-align%3A%20left%3B%20font-weight%3A%20400%3B%22%3EAutomated%20Machine%20Learning%20Documentation%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FAutomatedMLDocs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Faka.ms%2FAutomatedMLDocs%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22text-align%3A%20left%3B%20font-weight%3A%20400%3B%22%3EWhat%20is%20Automated%20Machine%20Learning%3F%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FAutomatedML%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Faka.ms%2FAutomatedML%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22text-align%3A%20left%3B%20font-weight%3A%20400%3B%22%3EModel%20Interpretability%20with%20Azure%20ML%20Service%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FAutomatedML%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Faka.ms%2F%3C%2FA%3E%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FAzureMLModelInterpretability%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzureMLModelInterpretability%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22text-align%3A%20left%3B%20font-weight%3A%20400%3B%22%3EAzure%20Notebooks%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FAzureNB%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Faka.ms%2FAzureNB%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22text-align%3A%20left%3B%20font-weight%3A%20400%3B%22%3EPython%20Microsoft%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FPythonMS%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Faka.ms%2FPythonMS%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22text-align%3A%20left%3B%20font-weight%3A%20400%3B%22%3EAzure%20ML%20for%20VS%20Code%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FAzureMLforVSCode%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eaka.ms%2FAzureMLforVSCode%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22text-align%3A%20left%3B%20font-weight%3A%20400%3B%22%3EAutomated%20and%20Interpretable%20Machine%20Learning%3A%20%3CA%20href%3D%22https%3A%2F%2Fmedium.com%2Fmicrosoftazure%2Fautomated-and-interpretable-machine-learning-d07975741298%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmedium.com%2Fmicrosoftazure%2Fautomated-and-interpretable-machine-learning-d07975741298%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22text-align%3A%20left%3B%20font-weight%3A%20400%3B%22%3EInterpretable%20Machine%20Learning%20Book%20by%20Christoph%20Molnar%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fchristophm.github.io%2Finterpretable-ml-book%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fchristophm.github.io%2Finterpretable-ml-book%2F%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-870819%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20organized%20a%20few%20seminars%20at%20the%20University%20of%20California%2C%20Berkeley%20around%20the%20topic%20of%20Ethics%20in%20AI.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-870819%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EEducation%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMachine%20Learning%20Services%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EModel%20Interpretability%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EUC%20Berkeley%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E

On September 9th, 10th and 11th, 2019, we organized a few seminars at the University of California, Berkeley around the topic of Ethics in AI. Specifically, we shared a few insights and practical demos on how to make machine learning models interpretable and accessible with Azure Machine Learning. In the next few paragraphs, we summarize the most important aspects presented during our seminars:

  1. How to interpret your model
  2. Interpretability during training
  3. Interpretability at inferencing time

 

1.  How to interpret your model

When it comes to predictive modeling, you have to make a trade-off: do you just want to know what is predicted? For example, the probability that a customer will churn or how effective some drug will be for a patient. Or do you want to know why the prediction was made and possibly pay for the interpretability with a drop in predictive performance?

In this section we briefly explain how you can explain why your model made the predictions it did with the various interpretability packages of the Azure Machine Learning Python SDK.

During the training phase of the development cycle, model designers and evaluators can use interpretability output of a model to verify hypotheses and build trust with stakeholders. They also use the insights into the model for debugging, validating model behavior matches their objectives, and to check for bias.

In machine learning, features are the data fields used to predict a target data point. For example, to predict credit risk, data fields for age, account size, and account age might be used. In this case, age, account size, and account age are features. Feature importance tells you how each data field affected the model’s predictions. For example, age may be heavily used in the prediction while account size and age don’t affect the prediction accuracy significantly. This process allows data scientists to explain resulting predictions, so that stakeholders have visibility into what data points are most important in the model.

Using these tools, you can explain machine learning models globally on all data, or locally on a specific data point using the state-of-art technologies in an easy-to-use and scalable fashion.

The interpretability classes are made available through multiple SDK packages. Learn how to install SDK packages for Azure Machine Learning.

 

  • azureml.explain.model, the main package, containing functionalities supported by Microsoft.

  • azureml.contrib.explain.model, preview, and experimental functionalities that you can try.

  • azureml.train.automl.automlexplainer package for interpreting automated machine learning models.

You can apply the interpretability classes and methods to understand the model’s global behavior or specific predictions. The former is called global explanation and the latter is called local explanation.

The methods can be also categorized based on whether the method is model agnostic or model specific. Some methods target certain type of models. For example, SHAP’s tree explainer only applies to tree-based models. Some methods treat the model as a black box, such as mimic explainer or SHAP’s kernel explainer. The explain package leverages these different approaches based on data sets, model types, and use cases.

The output is a set of information on how a given model makes its prediction, such as:

  • Global/local relative feature importance
  • Global/local feature and prediction relationship

There are two sets of explainers: Direct Explainers and Meta Explainers in the SDK.

Direct explainers come from integrated libraries. The SDK wraps all the explainers so that they expose a common API and output format. If you are more comfortable directly using these explainers, you can directly invoke them instead of using the common API and output format. The following table lists the direct explainers available in the SDK:

Meta explainers automatically select a suitable direct explainer and generate the best explanation info based on the given model and data sets. The meta explainers leverage all the libraries (SHAP, LIME, Mimic, etc.) that we have integrated or developed. The following are the meta explainers available in the SDK:

  • Tabular Explainer: Used with tabular datasets.
  • Text Explainer: Used with text datasets.
  • Image Explainer: Used with image datasets.

 

2. Interpretability during training

To initialize an explainer object, you need to pass your model and some training data to the explainer's constructor. You can also optionally pass in feature names and output class names (if doing classification) which will be used to make your explanations and visualizations more informative. Here is how to instantiate an explainer object using TabularExplainer, MimicExplainer, and PFIExplainer locally. TabularExplainer is calling one of the three SHAP explainers underneath (TreeExplainer, DeepExplainer, or KernelExplainer), and is automatically selecting the most appropriate one for your use case. You can however, call each of its three underlying explainers directly:

 

 

from azureml.explain.model.tabular_explainer import TabularExplainer
# "features" and "classes" fields are optional
explainer = TabularExplainer(model,
                             x_train,
                             features=breast_cancer_data.feature_names,
                             classes=classes)

 

 

Global visualizations

The following plots provide a global view of the trained model along with its predictions and explanations.

Plot

Description

Data Exploration

An overview of the dataset along with prediction values.

Global Importance

Shows the top K (configurable K) important features globally. This chart is useful for understanding the global behavior of the underlying model.

Explanation Exploration

Demonstrates how a feature is responsible for making a change in model’s prediction values (or probability of prediction values).

Summary

Uses a signed local feature importance values across all data points to show the distribution of the impact each feature has on the prediction value.

image1.png

 

Local visualizations

You can click on any individual data point at any time of the preceding plots to load the local feature importance plot for the given data point.

Plot

Description

Local Importance

Shows the top K (configurable K) important features globally. This chart is useful for understanding the local behavior of the underlying model on a specific data point.

Perturbation Exploration

Allows you to change feature values of the selected data point and observe how those changes will affect prediction value.

Individual Conditional Expectation (ICE)

Allows you to change a feature value from a minimum value to a maximum value to see how the data point's prediction changes when a feature changes.

image2.png

3. Interpretability at inferencing time

The explainer can be deployed along with the original model and can be used at scoring time to provide the local explanation information. We also offer lighter-weight scoring explainers to make interpretability at inferencing time more performant. The process of deploying a lighter-weight scoring explainer is similar to deploying a model and includes the following steps:

  • Create an explanation object (e.g., using TabularExplainer):

 

 

from azureml.contrib.explain.model.tabular_explainer import TabularExplainer
 
explainer = TabularExplainer(model,
                             initialization_examples=x_train,
                             features=dataset_feature_names,
                             classes=dataset_classes,
                             transformations=transformations)

 

 

  • Create a scoring explainer using the explanation object:

 

 

from azureml.contrib.explain.model.scoring.scoring_explainer import KernelScoringExplainer, save
 
# create a lightweight explainer at scoring time
scoring_explainer = KernelScoringExplainer(explainer)
 
# pickle scoring explainer
# pickle scoring explainer locally
OUTPUT_DIR = 'my_directory'
save(scoring_explainer, directory=OUTPUT_DIR, exist_ok=True)

 

 

  • Configure and register an image that uses the scoring explainer model:

 

 

# register explainer model using the path from ScoringExplainer.save - could be done on remote compute
# scoring_explainer.pkl is the filename on disk, while my_scoring_explainer.pkl will be the filename in cloud storage
run.upload_file('my_scoring_explainer.pkl', os.path.join(OUTPUT_DIR, 'scoring_explainer.pkl'))
 
scoring_explainer_model = run.register_model(model_name='my_scoring_explainer',
                                             model_path='my_scoring_explainer.pkl')

print(scoring_explainer_model.name, scoring_explainer_model.id, scoring_explainer_model.version, sep = '\t')

 

 

 

To see the full tutorial we presented at UC Berkeley, see Model interpretability with Azure Machine Learning. To see a collection of Jupyter notebooks that demonstrate the instructions above for different data science scenarios, see the Azure Machine Learning Interpretability sample notebooks.

 

To learn more, you can also read the following articles and notebooks: