{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":24339,"path":"intelligent-experiences/predictive-intelligence/predictive-intel-explainability.md","title":"Model Explainability","bundle":null,"doc_type":null,"release":"australia","body":"\n# Model Explainability\n\nAnalyze the importance of each input field to your model's predictions using model explainability. Create a Workflow Classification model that includes a graphical analysis of feature importance by executing the provided script.\n\n## Before you begin\n\n-   This method uses the Workflow Classification Solution API, instead of the Solution Definition form, to create and train a model with explainability added. For information about the components of Workflow Classification models, see [Create and train a classification solution](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/predictive-intelligence/create-solution-definition.md).\n-   Role required: ml\\_admin or admin\n\n## About this task\n\nModel explainability helps identify the key features that influence the model's predictions during training.\n\n**Note:** Explainability can't be added to an existing model. This method uses a script to create and train a new Workflow Classification model. For more information about scripting the creation of Classification solutions, see [ClassificationSolution - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/server-api-reference/ClassificationSolutionAPI.md).\n\nThe script provided in the procedure creates and trains a model with explainability set to true. On the new model's solution form, an additional tab labeled **Feature Importance** appears. This tab offers a graph of the relative contribution of each input to the prediction.\\[Omitted image \"predictive-intel-explainability1.png\"\\] Alt text: On the Solution form, the Feature Importance tab is highlighted. In the output \\(predicted\\) field, the value Global is selected, and an example graph is displayed.\n\n## Procedure\n\n1.  Navigate to **All** &gt; **System Definition** &gt; **Scripts - Background**.\n\n2.  Edit the query filter and table, field, and variable values in the following script according to your planned model, then execute the script.\n\n    ```\n    // Define a dataset\n                        var myIncidentData = new sn_ml.DatasetDefinition({\n                        'tableName': 'incident',\n                        'fieldNames': ['category', 'short_description', 'sys_updated_by', 'assignment_group', 'description', 'priority'],\n                        'encodedQuery': 'activeANYTHING'\n                        });\n                        \n                        // Define a classification solution definition with explainability field\n                        var mySolution = new sn_ml.ClassificationSolution({\n                        'label': 'model explainability',\n                        'dataset': myIncidentData,\n                        'predictedFieldName': 'category',\n                        'inputFieldNames': ['short_description', 'priority'],\n                        //setting the explainability field to true.\n                        'explainability': true,\n                        });\n                        \n                        // Add solution to ClassificationSolutionStore\n                        var my_unique_name = sn_ml.ClassificationSolutionStore.add(mySolution)\n                        \n                        // Submit training job\n                        var solutionVersion = mySolution.submitTrainingJob();\n                    \n    ```\n\n    **Note:** Substitute the query filter and table, field, and variable names in this script with your own values.\n\n3.  Navigate to the ML Solutions \\[ml\\_solution\\] table and open your new solution by selecting the value of its **Active** field.\n\n4.  On the solution form, locate and open the **Feature Importance** tab.\n\n    **Feature Importance** displays a drop-down list.\n\n    \\[Omitted image \"explainability-supplement.png\"\\] Alt text: On the Feature Importance tab, the drop-down list containing the range of possible classes for the output field.\n\n    -   The label for this drop-down list is the name of your output \\(predicted\\) field, so the label is specific to each model.\n    -   The values in the drop-down list are the possible output classes for your output field, plus the **Global** option.\n<table id=\"choicetable_afh_pny_12c\"><thead><tr><th align=\"left\" id=\"d359437e157\">\n\nList option\n\n</th><th align=\"left\" id=\"d359437e160\">\n\nDescription\n\n</th></tr></thead><tbody><tr><td id=\"d359437e166\">\n\n**__Global__**\n\n</td><td>\n\nProvides an overview of how the model behaves across all predictions, showing the overall impact of each input feature.Select **Global** to open a graph of the importance of your input fields to predictions for all output classes as a whole.\n\n</td></tr><tr><td id=\"d359437e181\">\n\n**`Your output class value`**\n\n</td><td>\n\nFocuses on the model's behavior for the chosen class only, showing how input features contribute to predictions on a per-class basis.Select one of the possible output classes to open a graph of the importance of your input fields to predictions for that class.\n\n</td></tr></tbody>\n</table>5.  Launch the graphical analysis by selecting a value from the drop-down list.\n\n    The y axis shows your input fields and the x axis shows the numerical importance for each input. The label of the graph reflects the class that you chose in the drop-down list. \\[Omitted image \"predictive-intel-explainability2.png\"\\] Alt text: On the Feature Importance tab, one of the possible output classes is selected. An example graph is displayed, illustrating the importance of the input fields to predictions for this class.\n\n    You can hover over a bar to display the numerical percentage for each input's importance.\n\n\n## Result\n\nA positive importance value means that the input field increases the model's prediction score. A negative value means that the input field decreases the prediction score.\n\n## What to do next\n\nConsider dropping input fields with low importance scores. Retrain your model after modification.\n\n**Related topics**  \n\n\n[Using Machine Learning APIs](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/predictive-intelligence/using-ml-apis.md)\n\n[ClassificationSolution - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/server-api-reference/ClassificationSolutionAPI.md)\n\n[Create and train a classification solution](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/predictive-intelligence/create-solution-definition.md)\n\n"}}