Repository: alteryx/evalml (python)

Issue:
explain_predictions_ functions should return top_k features by magnitude of SHAP value
Currently, the explain_predictions_ functions accept a top_k_features argument. By design, this returns the features with the top_k highest and top_k smallest shap values for a total of 2 * top_k features. 

The idea was to give users a sense of what drives a particular prediction up vs down but this approach can include some irrelevant information. For example, consider a prediction where every feature has a positive SHAP value but 10 features have really high Shap values and the smallest 5 have shap values close to 0. Passing top_k=5, would include the 5 features with near-zero shap values. It would be better to just return the 10 features with the highest shap value by magnitude.

FYI @kmax12 

Pull request:
Displaying the top_k features with largest shap value magnitudes
### Pull Request Description
Fixes #1360

FYI @RezaAkhtar

-----
*After creating the pull request: in order to pass the **release_notes_updated** check you will need to update the "Future Release" section of* `docs/source/release_notes.rst` *to include this pull request by adding :pr:`123`.*


Patch:
diff --git a/docs/source/release_notes.rst b/docs/source/release_notes.rst
index a39693f6..872abedf 100644
--- a/docs/source/release_notes.rst
+++ b/docs/source/release_notes.rst
@@ -5,6 +5,7 @@ Release Notes
     * Enhancements
         * Added ability to freeze hyperparameters for AutoMLSearch :pr:`1284`
         * Added the index id to the ``explain_predictions_best_worst`` output to help users identify which rows in their data are included :pr:`1365`
+        * The top_k features displayed in ``explain_predictions_*`` functions are now determined by the magnitude of shap values as opposed to the ``top_k`` largest and smallest shap values. :pr:`1374`
     * Fixes
         * Updated enum classes to show possible enum values as attributes :pr:`1391`
     * Changes
@@ -17,6 +18,12 @@ Release Notes
         * Removed ``category_encoders`` from test-requirements.txt :pr:`1373`
         * Tweak codecov.io settings again to avoid flakes :pr:`1413`
 
+.. warning::
+
+    **Breaking Changes**
+        * The ``top_k`` and ``top_k_features`` parameters in ``explain_predictions_*`` functions now return ``k`` features as opposed to ``2 * k`` features :pr:`1374`
+
+
 **v0.15.0 Oct. 29, 2020**
     * Enhancements
         * Added stacked ensemble component classes (``StackedEnsembleClassifier``, ``StackedEnsembleRegressor``) :pr:`1134`
diff --git a/docs/source/user_guide/model_understanding.ipynb b/docs/source/user_guide/model_understanding.ipynb
index 7d500921..cc7a7bab 100644
--- a/docs/source/user_guide/model_understanding.ipynb
+++ b/docs/source/user_guide/model_understanding.ipynb
@@ -330,7 +330,7 @@
     "from evalml.model_understanding.prediction_explanations import explain_prediction\n",
     "\n",
     "table = explain_prediction(pipeline=pipeline, input_features=X.iloc[3:4],\n",
-    "                           training_data=X, include_shap_values=True)\n",
+    "                           training_data=X, top_k=6, include_shap_values=True)\n",
     "print(table)"
    ]
   },
@@ -367,7 +367,7 @@
     "from evalml.model_understanding.prediction_explanations import explain_predictions_best_worst\n",
     "\n",
     "report = explain_predictions_best_worst(pipeline=pipeline, input_features=X, y_true=y,\n",
-    "                                        include_shap_values=True, num_to_explain=2)\n",
+    "                                        include_shap_values=True, top_k_features=6, num_to_explain=2)\n",
     "\n",
     "print(report)"
    ]
@@ -431,7 +431,8 @@
    "source": [
     "import json\n",
     "report = explain_predictions_best_worst(pipeline=pipeline, input_features=X, y_true=y,\n",
-    "                                        num_to_explain=1, include_shap_values=True, output_format=\"dict\")\n",
+    "                                        num_to_explain=1, top_k_features=6,\n",
+    "                                        include_shap_values=True, output_format=\"dict\")\n",
     "print(json.dumps(report, indent=2))"
    ]
   }
diff --git a/evalml/model_understanding/prediction_explanations/_user_interface.py b/evalml/model_understanding/prediction_explanations/_user_interface.py
index bb2ffe79..38b259a7 100644
--- a/evalml/model_understanding/prediction_explanations/_user_interface.py
+++ b/evalml/model_understanding/prediction_explanations/_user_interface.py
@@ -26,12 +26,13 @@ def _make_rows(shap_values, normalized_values, pipeline_features, top_k, include
           list(str)
     """
     tuples = [(value[0], feature_name) for feature_name, value in normalized_values.items()]
-    tuples = sorted(tuples)
 
-    if len(tuples) <= 2 * top_k:
-        features_to_display = reversed(tuples)
-    else:
-        features_to_display = tuples[-top_k:][::-1] + tuples[:top_k][::-1]
+    # Sort the features s.t the top_k w the largest shap value magnitudes are the first
+    # top_k elements
+    tuples = sorted(tuples, key=lambda x: abs(x[0]), reverse=True)
+
+    # Then sort such that the SHAP values go from most positive to most negative
+    features_to_display = reversed(sorted(tuples[:top_k]))
 
     rows = []
     for value, feature_name in features_to_display:


Test patch:
diff --git a/evalml/tests/model_understanding_tests/prediction_explanations_tests/test_explainers.py b/evalml/tests/model_understanding_tests/prediction_explanations_tests/test_explainers.py
index e051acb7..a4c61f4b 100644
--- a/evalml/tests/model_understanding_tests/prediction_explanations_tests/test_explainers.py
+++ b/evalml/tests/model_understanding_tests/prediction_explanations_tests/test_explainers.py
@@ -34,27 +34,25 @@ def test_explain_prediction_value_error(test_features):
 
 explain_prediction_answer = """Feature Name Feature Value Contribution to Prediction
                                =========================================================
-                                 d           40.00          ++++
-                                 a           10.00          +++
-                                 c           30.00          --
-                                 b           20.00          ----""".splitlines()
+                                 d           40.00          +++++
+                                 b           20.00          -----""".splitlines()
 
 explain_prediction_regression_dict_answer = {
     "explanations": [{
-        "feature_names": ["d", "a", "c", "b"],
-        "feature_values": [40, 10, 30, 20],
-        "qualitative_explanation": ["++++", "+++", "--", "----"],
-        "quantitative_explanation": [None, None, None, None],
+        "feature_names": ["d", "b"],
+        "feature_values": [40, 20],
+        "qualitative_explanation": ["+++++", "-----"],
+        "quantitative_explanation": [None, None],
         "class_name": None
     }]
 }
 
 explain_prediction_binary_dict_answer = {
     "explanations": [{
-        "feature_names": ["d", "a", "c", "b"],
-        "feature_values": [40, 10, 30, 20],
-        "qualitative_explanation": ["++++", "+++", "--", "----"],
-        "quantitative_explanation": [None, None, None, None],
+        "feature_names": ["d", "b"],
+        "feature_values": [40, 20],
+        "qualitative_explanation": ["+++++", "-----"],
+        "quantitative_explanation": [None, None],
         "class_name": "class_1"
     }]
 }
@@ -63,10 +61,8 @@ explain_prediction_multiclass_answer = """Class: class_0
 
         Feature Name Feature Value Contribution to Prediction
        =========================================================
-            a           10.00                +
-            b           20.00                +
-            c           30.00                -
-            d           40.00                -
+            a           10.00               +++++
+            c           30.00                ---
 
 
         Class: class_1
@@ -75,36 +71,32 @@ explain_prediction_multiclass_answer = """Class: class_0
        =========================================================
             a           10.00               +++
             b           20.00               ++
-            c           30.00               -
-            d           40.00               --
 
 
         Class: class_2
 
         Feature Name Feature Value Contribution to Prediction
         =========================================================
-            a          10.00            +
-            b          20.00            +
             c          30.00           ---
             d          40.00           ---
             """.splitlines()
 
 explain_prediction_multiclass_dict_answer = {
     "explanations": [
-        {"feature_names": ["a", "b", "c", "d"],
-         "feature_values": [10, 20, 30, 40],
-         "qualitative_explanation": ["+", "+", "-", "-"],
-         "quantitative_explanation": [None] * 4,
+        {"feature_names": ["a", "c"],
+         "feature_values": [10, 30],
+         "qualitative_explanation": ["+++++", "---"],
+         "quantitative_explanation": [None, None],
          "class_name": "class_0"},
-        {"feature_names": ["a", "b", "c", "d"],
-         "feature_values": [10, 20, 30, 40],
-         "qualitative_explanation": ["+++", "++", "-", "--"],
-         "quantitative_explanation": [None] * 4,
+        {"feature_names": ["a", "b"],
+         "feature_values": [10, 20],
+         "qualitative_explanation": ["+++", "++"],
+         "quantitative_explanation": [None, None],
          "class_name": "class_1"},
-        {"feature_names": ["a", "b", "c", "d"],
-         "feature_values": [10, 20, 30, 40],
-         "qualitative_explanation": ["+", "+", "---", "---"],
-         "quantitative_explanation": [None] * 4,
+        {"feature_names": ["c", "d"],
+         "feature_values": [30, 40],
+         "qualitative_explanation": ["---", "---"],
+         "quantitative_explanation": [None, None],
          "class_name": "class_2"},
     ]
 }
@@ -113,36 +105,36 @@ explain_prediction_multiclass_dict_answer = {
 @pytest.mark.parametrize("problem_type,output_format,shap_values,normalized_shap_values,answer",
                          [(ProblemTypes.REGRESSION,
                            "text",
-                           {"a": [1], "b": [-2], "c": [-0.25], "d": [2]},
-                           {"a": [0.5], "b": [-0.75], "c": [-0.25], "d": [0.75]},
+                           {"a": [1], "b": [-2.1], "c": [-0.25], "d": [2.3]},
+                           {"a": [0.5], "b": [-2.1], "c": [-0.25], "d": [2.3]},
                            explain_prediction_answer),
                           (ProblemTypes.REGRESSION,
                            "dict",
-                           {"a": [1], "b": [-2], "c": [-0.25], "d": [2]},
-                           {"a": [0.5], "b": [-0.75], "c": [-0.25], "d": [0.75]},
+                           {"a": [1], "b": [-2.1], "c": [-0.25], "d": [2.3]},
+                           {"a": [0.5], "b": [-2.1], "c": [-0.25], "d": [2.3]},
                            explain_prediction_regression_dict_answer
                            ),
                           (ProblemTypes.BINARY,
                            "text",
-                           [{}, {"a": [1], "b": [-2], "c": [-0.25], "d": [2]}],
-                           [{}, {"a": [0.5], "b": [-0.75], "c": [-0.25], "d": [0.75]}],
+                           [{}, {"a": [0.5], "b": [-0.89], "c": [0.33], "d": [0.89]}],
+                           [{}, {"a": [0.5], "b": [-0.89], "c": [-0.25], "d": [0.89]}],
                            explain_prediction_answer),
                           (ProblemTypes.BINARY,
                            "dict",
-                           [{}, {"a": [1], "b": [-2], "c": [-0.25], "d": [2]}],
-                           [{}, {"a": [0.5], "b": [-0.75], "c": [-0.25], "d": [0.75]}],
+                           [{}, {"a": [0.5], "b": [-0.89], "c": [0.33], "d": [0.89]}],
+                           [{}, {"a": [0.5], "b": [-0.89], "c": [-0.25], "d": [0.89]}],
                            explain_prediction_binary_dict_answer),
                           (ProblemTypes.MULTICLASS,
                            "text",
                            [{}, {}, {}],
-                           [{"a": [0.1], "b": [0.09], "c": [-0.04], "d": [-0.06]},
+                           [{"a": [1.1], "b": [0.09], "c": [-0.53], "d": [-0.06]},
                             {"a": [0.53], "b": [0.24], "c": [-0.15], "d": [-0.22]},
                             {"a": [0.03], "b": [0.02], "c": [-0.42], "d": [-0.47]}],
                            explain_prediction_multiclass_answer),
                           (ProblemTypes.MULTICLASS,
                            "dict",
                            [{}, {}, {}],
-                           [{"a": [0.1], "b": [0.09], "c": [-0.04], "d": [-0.06]},
+                           [{"a": [1.1], "b": [0.09], "c": [-0.53], "d": [-0.06]},
                             {"a": [0.53], "b": [0.24], "c": [-0.15], "d": [-0.22]},
                             {"a": [0.03], "b": [0.02], "c": [-0.42], "d": [-0.47]}],
                            explain_prediction_multiclass_dict_answer)
diff --git a/evalml/tests/model_understanding_tests/prediction_explanations_tests/test_user_interface.py b/evalml/tests/model_understanding_tests/prediction_explanations_tests/test_user_interface.py
index 69c76a5b..6d8e5611 100644
--- a/evalml/tests/model_understanding_tests/prediction_explanations_tests/test_user_interface.py
+++ b/evalml/tests/model_understanding_tests/prediction_explanations_tests/test_user_interface.py
@@ -18,9 +18,9 @@ from evalml.model_understanding.prediction_explanations._user_interface import (
 make_rows_test_cases = [({"a": [0.2], "b": [0.1]}, 3, [["a", "1.20", "++"], ["b", "1.10", "+"]]),
                         ({"a": [0.3], "b": [-0.9], "c": [0.5],
                           "d": [0.33], "e": [-0.67], "f": [-0.2],
-                          "g": [0.71]}, 3,
-                         [["g", "1.71", "++++"], ["c", "1.50", "+++"], ["d", "1.33", "++"],
-                          ["f", "0.80", "--"], ["e", "0.33", "----"], ["b", "0.10", "-----"]]),
+                          "g": [0.71]}, 4,
+                         [["g", "1.71", "++++"], ["c", "1.50", "+++"],
+                          ["e", "0.33", "----"], ["b", "0.10", "-----"]]),
                         ({"a": [1.0], "f": [-1.0], "e": [0.0]}, 5,
                          [["a", "2.00", "+++++"], ["e", "1.00", "+"], ["f", "0.00", "-----"]])]
 
@@ -77,12 +77,12 @@ def test_make_json_serializable(value, answer):
 
 
 regression = {"a": [6.500], "b": [1.770], "c": [0.570],
-              "d": [-0.090], "e": [-0.290], "f": [-1.210],
+              "d": [-0.090], "e": [-0.290], "f": [-1.910],
               "foo": [0.01], "bar": [-0.02]}
 
 regression_normalized = {'a': [0.6214], 'b': [0.1692], 'bar': [-0.0019],
                          'c': [0.0544], 'd': [-0.0086], 'e': [-0.0277],
-                         'f': [-0.1156], 'foo': [0.0001]}
+                         'f': [-0.8], 'foo': [0.0001]}
 
 regression_pipeline_features = pd.DataFrame({"a": 7.5, "b": 2.77, "c": 1.57, "d": 0.91, "e": 0.71, "f": -0.21,
                                              "foo": -20, "bar": -30}, index=[31])
@@ -92,100 +92,87 @@ regression_table = """Feature Name  Feature Value Contribution to Prediction
                       =========================================================
                       a 7.50 ++++
                       b 2.77 +
-                      c 1.57 +
-                      d 0.91 -
-                      e 0.71 -
-                      f -0.21 -""".splitlines()
+                      f -0.21 -----""".splitlines()
 
 regression_table_shap = """Feature Name Feature Value Contribution to Prediction SHAP Value
                          ======================================================================
                          a 7.50 ++++ 6.50
                          b 2.77 + 1.77
-                         c 1.57 + 0.57
-                         d 0.91 - -0.09
-                         e 0.71 - -0.29
-                         f -0.21 - -1.21""".splitlines()
+                         f -0.21 ----- -1.91""".splitlines()
 
 regression_dict = {
     "explanations": [{
-        "feature_names": ["a", "b", "c", "d", "e", "f"],
-        "feature_values": [7.5, 2.77, 1.57, 0.91, 0.71, -0.21],
-        "qualitative_explanation": ["++++", "+", "+", "-", "-", "-"],
-        "quantitative_explanation": [None, None, None, None, None, None],
+        "feature_names": ["a", "b", "f"],
+        "feature_values": [7.5, 2.77, -0.21],
+        "qualitative_explanation": ["++++", "+", "-----"],
+        "quantitative_explanation": [None, None, None],
         "class_name": None
     }]
 }
 
 regression_dict_shap = {
     "explanations": [{
-        "feature_names": ["a", "b", "c", "d", "e", "f"],
-        "feature_values": [7.5, 2.77, 1.57, 0.91, 0.71, -0.21],
-        "qualitative_explanation": ["++++", "+", "+", "-", "-", "-"],
-        "quantitative_explanation": [6.50, 1.77, 0.57, -0.09, -0.29, -1.21],
+        "feature_names": ["a", "b", "f"],
+        "feature_values": [7.5, 2.77, -0.21],
+        "qualitative_explanation": ["++++", "+", "-----"],
+        "quantitative_explanation": [6.50, 1.77, -1.91],
         "class_name": None
     }]
 }
 
 binary = [{"a": [0], "b": [0], "c": [0],
            "d": [0], "e": [0], "f": [0], "foo": [-1]},
-          {"a": [1.180], "b": [1.120], "c": [0.000],
-           "d": [-2.560], "e": [-2.800], "f": [-2.900], "foo": [-1]}]
+          {"a": [1.180], "b": [0.0], "c": [1.120],
+           "d": [-0.560], "e": [-2.600], "f": [-0.900], "foo": [-1]}]
 
 binary_normalized = [{'a': [0.0], 'b': [0.0], 'c': [0.0], 'd': [0.0], 'e': [0.0], 'f': [0.0], 'foo': [-1.0]},
-                     {'a': [0.102], 'b': [0.097], 'c': [0.0], 'd': [-0.225],
-                      'e': [-0.2422], 'f': [-0.251], 'foo': [-0.087]}]
+                     {'a': [0.16], 'b': [0.0], 'c': [0.15],
+                     'd': [-0.08], 'e': [-0.35], 'f': [-0.12], 'foo': [-0.14]}]
 binary_pipeline_features = pd.DataFrame({"a": 2.18, "b": 2.12, "c": 1.0, "d": -1.56, "e": -1.8, "f": -1.9,
                                          "foo": -20}, index=[23])
 
 binary_table = """Feature Name Feature Value Contribution to Prediction
                 =========================================================
                 a 2.18 +
-                b 2.12 +
                 c 1.00 +
-                d -1.56 --
-                e -1.80 --
-                f -1.90 --""".splitlines()
+                e -1.80 --""".splitlines()
 
 binary_table_shap = """Feature Name Feature Value Contribution to Prediction SHAP Value
                     ======================================================================
                      a 2.18 + 1.18
-                     b 2.12 + 1.12
-                     c 1.00 + 0.00
-                     d -1.56 -- -2.56
-                     e -1.80 -- -2.80
-                     f -1.90 -- -2.90""".splitlines()
+                     c 1.00 + 1.12
+                     e -1.80 -- -2.60""".splitlines()
 
 binary_dict = {
     "explanations": [{
-        "feature_names": ["a", "b", "c", "d", "e", "f"],
-        "feature_values": [2.180, 2.120, 1.000, -1.560, -1.800, -1.900],
-        "qualitative_explanation": ["+", "+", "+", "--", "--", "--"],
-        "quantitative_explanation": [None, None, None, None, None, None],
+        "feature_names": ["a", "c", "e"],
+        "feature_values": [2.180, 1.0, -1.80],
+        "qualitative_explanation": ["+", "+", "--"],
+        "quantitative_explanation": [None, None, None],
         "class_name": "1"
     }]
 }
 
 binary_dict_shap = {
     "explanations": [{
-        "feature_names": ["a", "b", "c", "d", "e", "f"],
-        "feature_values": [2.180, 2.120, 1.000, -1.560, -1.800, -1.900],
-        "qualitative_explanation": ["+", "+", "+", "--", "--", "--"],
-        "quantitative_explanation": [1.180, 1.120, 0.000, -2.560, -2.800, -2.900],
+        "feature_names": ["a", "c", "e"],
+        "feature_values": [2.180, 1.0, -1.80],
+        "qualitative_explanation": ["+", "+", "--"],
+        "quantitative_explanation": [1.180, 1.120, -2.60],
         "class_name": "1"
     }]
 }
 
 multiclass = [{"a": [0], "b": [0], "c": [0],
-               "d": [0], "e": [0], "f": [0], "foo": [-1]},
+               "d": [0.11], "e": [0.18], "f": [0], "foo": [-1]},
               {"a": [1.180], "b": [1.120], "c": [0.000], "d": [-2.560],
                "e": [-2.800], "f": [-2.900], "foo": [-1]},
               {"a": [0.680], "b": [0.000], "c": [0.000],
-               "d": [-1.840], "e": [-2.040], "f": [-2.680], "foo": [-1]}]
+               "d": [-2.040], "e": [-1.840], "f": [-2.680], "foo": [-1]}]
 
-multiclass_normalized = [{'a': [0.0], 'b': [0.0], 'c': [0.0], 'd': [0.0], 'e': [0.0], 'f': [0.0], 'foo': [-1.0]},
+multiclass_normalized = [{'a': [0.0], 'b': [0.0], 'c': [0.0], 'd': [0.07], 'e': [0.08], 'f': [0.0], 'foo': [-1.0]},
                          {'a': [0.102], 'b': [0.097], 'c': [0.0], 'd': [-0.221], 'e': [-0.242], 'f': [-0.251], 'foo': [-0.0865]},
-                         {'a': [0.0825], 'b': [0.0], 'c': [0.0], 'd': [-0.223], 'e': [-0.247], 'f': [-0.325], 'foo': [-0.121]}]
-
+                         {'a': [0.08], 'b': [0.0], 'c': [0.0], 'd': [-0.25], 'e': [-0.22], 'f': [-0.33], 'foo': [-0.12]}]
 multiclass_pipeline_features = pd.DataFrame({"a": 2.18, "b": 2.12, "c": 1.0, "d": -1.56, "e": -1.8, "f": -1.9,
                                              "foo": 30}, index=[10])
 
@@ -193,11 +180,8 @@ multiclass_table = """Class: 0
 
                     Feature Name Feature Value Contribution to Prediction
                     =========================================================
-                    f -1.90 +
                     e -1.80 +
                     d -1.56 +
-                    b 2.12 +
-                    a 2.18 +
                     foo 30.00 -----
 
 
@@ -205,9 +189,6 @@ multiclass_table = """Class: 0
 
                     Feature Name Feature Value Contribution to Prediction
                     =========================================================
-                    a 2.18 +
-                    b 2.12 +
-                    c 1.00 +
                     d -1.56 --
                     e -1.80 --
                     f -1.90 --
@@ -217,22 +198,16 @@ multiclass_table = """Class: 0
 
                     Feature Name Feature Value Contribution to Prediction
                     =========================================================
-                    a 2.18 +
-                    c 1.00 +
-                    b 2.12 +
-                    d -1.56 --
                     e -1.80 --
+                    d -1.56 --
                     f -1.90 --""".splitlines()
 
 multiclass_table_shap = """Class: 0
 
                          Feature Name Feature Value Contribution to Prediction SHAP Value
                          ======================================================================
-                         f -1.90 + 0.00
-                         e -1.80 + 0.00
-                         d -1.56 + 0.00
-                         b 2.12 + 0.00
-                         a 2.18 + 0.00
+                         e -1.80 + 0.18
+                         d -1.56 + 0.11
                          foo 30.00 ----- -1.00
 
 
@@ -240,9 +215,6 @@ multiclass_table_shap = """Class: 0
 
                          Feature Name Feature Value Contribution to Prediction SHAP Value
                          ======================================================================
-                         a 2.18 + 1.18
-                         b 2.12 + 1.12
-                         c 1.00 + 0.00
                          d -1.56 -- -2.56
                          e -1.80 -- -2.80
                          f -1.90 -- -2.90
@@ -252,49 +224,46 @@ multiclass_table_shap = """Class: 0
 
                          Feature Name Feature Value Contribution to Prediction SHAP Value
                          ======================================================================
-                         a 2.18 + 0.68
-                         c 1.00 + 0.00
-                         b 2.12 + 0.00
-                         d -1.56 -- -1.84
-                         e -1.80 -- -2.04
+                         e -1.80 -- -1.84
+                         d -1.56 -- -2.04
                          f -1.90 -- -2.68""".splitlines()
 
 multiclass_dict = {
     "explanations": [
-        {"feature_names": ["f", "e", "d", "b", "a", "foo"],
-         "feature_values": [-1.9, -1.8, -1.56, 2.12, 2.18, 30],
-         "qualitative_explanation": ["+", "+", "+", "+", "+", "-----"],
-         "quantitative_explanation": [None, None, None, None, None, None],
+        {"feature_names": ["e", "d", "foo"],
+         "feature_values": [-1.8, -1.56, 30],
+         "qualitative_explanation": ["+", "+", "-----"],
+         "quantitative_explanation": [None, None, None],
          "class_name": "0"},
-        {"feature_names": ["a", "b", "c", "d", "e", "f"],
-         "feature_values": [2.18, 2.12, 1.0, -1.56, -1.8, -1.9],
-         "qualitative_explanation": ["+", "+", "+", "--", "--", "--"],
-         "quantitative_explanation": [None, None, None, None, None, None],
+        {"feature_names": ["d", "e", "f"],
+         "feature_values": [-1.56, -1.8, -1.9],
+         "qualitative_explanation": ["--", "--", "--"],
+         "quantitative_explanation": [None, None, None],
          "class_name": "1"},
-        {"feature_names": ["a", "c", "b", "d", "e", "f"],
-         "feature_values": [2.18, 1.0, 2.12, -1.56, -1.8, -1.9],
-         "qualitative_explanation": ["+", "+", "+", "--", "--", "--"],
-         "quantitative_explanation": [None, None, None, None, None, None],
+        {"feature_names": ["e", "d", "f"],
+         "feature_values": [-1.8, -1.56, -1.9],
+         "qualitative_explanation": ["--", "--", "--"],
+         "quantitative_explanation": [None, None, None],
          "class_name": "2"}
     ]
 }
 
 multiclass_dict_shap = {
     "explanations": [
-        {"feature_names": ["f", "e", "d", "b", "a", "foo"],
-         "feature_values": [-1.9, -1.8, -1.56, 2.12, 2.18, 30],
-         "qualitative_explanation": ["+", "+", "+", "+", "+", "-----"],
-         "quantitative_explanation": [0, 0, 0, 0, 0, -1],
+        {"feature_names": ["e", "d", "foo"],
+         "feature_values": [-1.8, -1.56, 30],
+         "qualitative_explanation": ["+", "+", "-----"],
+         "quantitative_explanation": [0.18, 0.11, -1],
          "class_name": "0"},
-        {"feature_names": ["a", "b", "c", "d", "e", "f"],
-         "feature_values": [2.18, 2.12, 1.0, -1.56, -1.8, -1.9],
-         "qualitative_explanation": ["+", "+", "+", "--", "--", "--"],
-         "quantitative_explanation": [1.180, 1.120, 0.000, -2.560, -2.800, -2.900],
+        {"feature_names": ["d", "e", "f"],
+         "feature_values": [-1.56, -1.8, -1.9],
+         "qualitative_explanation": ["--", "--", "--"],
+         "quantitative_explanation": [-2.56, -2.8, -2.9],
          "class_name": "1"},
-        {"feature_names": ["a", "c", "b", "d", "e", "f"],
-         "feature_values": [2.18, 1.0, 2.12, -1.56, -1.8, -1.9],
-         "qualitative_explanation": ["+", "+", "+", "--", "--", "--"],
-         "quantitative_explanation": [0.680, 0.000, 0.000, -1.840, -2.040, -2.680],
+        {"feature_names": ["e", "d", "f"],
+         "feature_values": [-1.8, -1.56, -1.9],
+         "qualitative_explanation": ["--", "--", "--"],
+         "quantitative_explanation": [-1.84, -2.04, -2.68],
          "class_name": "2"}
     ]
 }