02. Basic example

Computing SHAP values for different classifiers to understand which type of SHAP explainers can be used with the different algorithms.

  • GaussianNB
  • LogisticRegression
  • DecisionTreeClassifier
  • RandomForestClassifier
  • XGBClassifier
  • MLPClassifier
  • SVC
  • ExtraTreesClassifier

Out:

<IPython.core.display.HTML object>

--------------------------------------------------------------------------------
Classifier: GaussianNB()
Kernel type: <class 'shap.explainers._kernel.Kernel'>

  0%|          | 0/375 [00:00<?, ?it/s]
  3%|2         | 11/375 [00:00<00:03, 102.76it/s]
  6%|5         | 22/375 [00:00<00:03, 102.78it/s]
  9%|8         | 33/375 [00:00<00:03, 103.24it/s]
 12%|#1        | 44/375 [00:00<00:03, 103.30it/s]
 15%|#4        | 55/375 [00:00<00:03, 102.90it/s]
 18%|#7        | 66/375 [00:00<00:02, 103.08it/s]
 21%|##        | 77/375 [00:00<00:02, 101.48it/s]
 23%|##3       | 88/375 [00:00<00:02, 101.08it/s]
 26%|##6       | 99/375 [00:00<00:02, 101.66it/s]
 29%|##9       | 110/375 [00:01<00:02, 101.15it/s]
 32%|###2      | 121/375 [00:01<00:02, 101.91it/s]
 35%|###5      | 132/375 [00:01<00:02, 102.28it/s]
 38%|###8      | 143/375 [00:01<00:02, 102.70it/s]
 41%|####1     | 154/375 [00:01<00:02, 102.56it/s]
 44%|####4     | 165/375 [00:01<00:02, 102.56it/s]
 47%|####6     | 176/375 [00:01<00:01, 103.07it/s]
 50%|####9     | 187/375 [00:01<00:01, 102.46it/s]
 53%|#####2    | 198/375 [00:01<00:01, 102.38it/s]
 56%|#####5    | 209/375 [00:02<00:01, 102.44it/s]
 59%|#####8    | 220/375 [00:02<00:01, 102.31it/s]
 62%|######1   | 231/375 [00:02<00:01, 102.77it/s]
 65%|######4   | 242/375 [00:02<00:01, 103.28it/s]
 67%|######7   | 253/375 [00:02<00:01, 101.43it/s]
 70%|#######   | 264/375 [00:02<00:01, 101.24it/s]
 73%|#######3  | 275/375 [00:02<00:00, 101.26it/s]
 76%|#######6  | 286/375 [00:02<00:00, 101.95it/s]
 79%|#######9  | 297/375 [00:02<00:00, 100.08it/s]
 82%|########2 | 308/375 [00:03<00:00, 97.93it/s]
 85%|########4 | 318/375 [00:03<00:00, 97.61it/s]
 87%|########7 | 328/375 [00:03<00:00, 98.26it/s]
 90%|######### | 339/375 [00:03<00:00, 99.29it/s]
 93%|#########3| 350/375 [00:03<00:00, 99.85it/s]
 96%|#########6| 360/375 [00:03<00:00, 99.51it/s]
 99%|#########8| 370/375 [00:03<00:00, 99.61it/s]
100%|##########| 375/375 [00:03<00:00, 101.34it/s]
[[-0.21 -0.19 -0.22]
 [ 0.16  0.05  0.17]
 [-0.31  0.06 -0.31]
 ...
 [-0.1   0.07 -0.14]
 [ 0.15  0.03  0.16]
 [-0.2   0.15 -0.25]]
base value: 0.6256054145239283

  0%|          | 0/375 [00:00<?, ?it/s]
  3%|2         | 11/375 [00:00<00:03, 101.78it/s]
  6%|5         | 22/375 [00:00<00:03, 102.13it/s]
  9%|8         | 33/375 [00:00<00:03, 102.02it/s]
 12%|#1        | 44/375 [00:00<00:03, 102.35it/s]
 15%|#4        | 55/375 [00:00<00:03, 102.36it/s]
 18%|#7        | 66/375 [00:00<00:03, 102.06it/s]
 21%|##        | 77/375 [00:00<00:02, 102.16it/s]
 23%|##3       | 88/375 [00:00<00:02, 99.90it/s]
 26%|##6       | 99/375 [00:00<00:02, 99.82it/s]
 29%|##9       | 109/375 [00:01<00:02, 98.54it/s]
 32%|###1      | 119/375 [00:01<00:02, 98.81it/s]
 35%|###4      | 130/375 [00:01<00:02, 99.19it/s]
 38%|###7      | 141/375 [00:01<00:02, 100.04it/s]
 41%|####      | 152/375 [00:01<00:02, 100.48it/s]
 43%|####3     | 163/375 [00:01<00:02, 100.95it/s]
 46%|####6     | 174/375 [00:01<00:01, 101.39it/s]
 49%|####9     | 185/375 [00:01<00:01, 101.20it/s]
 52%|#####2    | 196/375 [00:01<00:01, 101.70it/s]
 55%|#####5    | 207/375 [00:02<00:01, 101.47it/s]
 58%|#####8    | 218/375 [00:02<00:01, 101.18it/s]
 61%|######1   | 229/375 [00:02<00:01, 100.59it/s]
 64%|######4   | 240/375 [00:02<00:01, 100.66it/s]
 67%|######6   | 251/375 [00:02<00:01, 96.18it/s]
 70%|######9   | 261/375 [00:02<00:01, 95.64it/s]
 72%|#######2  | 271/375 [00:02<00:01, 95.60it/s]
 75%|#######4  | 281/375 [00:02<00:00, 94.51it/s]
 78%|#######7  | 291/375 [00:02<00:00, 95.43it/s]
 80%|########  | 301/375 [00:03<00:00, 95.56it/s]
 83%|########2 | 311/375 [00:03<00:00, 93.69it/s]
 86%|########5 | 321/375 [00:03<00:00, 93.59it/s]
 88%|########8 | 331/375 [00:03<00:00, 93.89it/s]
 91%|######### | 341/375 [00:03<00:00, 92.25it/s]
 94%|#########3| 351/375 [00:03<00:00, 92.82it/s]
 96%|#########6| 361/375 [00:03<00:00, 92.53it/s]
 99%|#########8| 371/375 [00:03<00:00, 92.13it/s]
100%|##########| 375/375 [00:03<00:00, 97.72it/s]

--------------------------------------------------------------------------------
Classifier: LogisticRegression()
Kernel type: <class 'shap.explainers._kernel.Kernel'>

  0%|          | 0/375 [00:00<?, ?it/s]
  3%|2         | 10/375 [00:00<00:03, 92.00it/s]
  5%|5         | 20/375 [00:00<00:03, 92.27it/s]
  8%|8         | 30/375 [00:00<00:03, 94.71it/s]
 11%|#         | 40/375 [00:00<00:03, 94.61it/s]
 13%|#3        | 50/375 [00:00<00:03, 95.40it/s]
 16%|#6        | 60/375 [00:00<00:03, 95.48it/s]
 19%|#8        | 70/375 [00:00<00:03, 96.15it/s]
 21%|##1       | 80/375 [00:00<00:03, 95.55it/s]
 24%|##4       | 90/375 [00:00<00:03, 94.86it/s]
 27%|##6       | 100/375 [00:01<00:02, 94.56it/s]
 29%|##9       | 110/375 [00:01<00:02, 94.64it/s]
 32%|###2      | 121/375 [00:01<00:02, 97.43it/s]
 35%|###5      | 132/375 [00:01<00:02, 99.09it/s]
 38%|###8      | 143/375 [00:01<00:02, 100.91it/s]
 41%|####1     | 154/375 [00:01<00:02, 102.31it/s]
 44%|####4     | 165/375 [00:01<00:02, 103.05it/s]
 47%|####6     | 176/375 [00:01<00:01, 103.16it/s]
 50%|####9     | 187/375 [00:01<00:01, 102.42it/s]
 53%|#####2    | 198/375 [00:02<00:01, 102.38it/s]
 56%|#####5    | 209/375 [00:02<00:01, 102.81it/s]
 59%|#####8    | 220/375 [00:02<00:01, 103.48it/s]
 62%|######1   | 231/375 [00:02<00:01, 104.06it/s]
 65%|######4   | 242/375 [00:02<00:01, 104.10it/s]
 67%|######7   | 253/375 [00:02<00:01, 104.92it/s]
 70%|#######   | 264/375 [00:02<00:01, 105.27it/s]
 73%|#######3  | 275/375 [00:02<00:00, 105.37it/s]
 76%|#######6  | 286/375 [00:02<00:00, 104.71it/s]
 79%|#######9  | 297/375 [00:02<00:00, 105.04it/s]
 82%|########2 | 308/375 [00:03<00:00, 105.40it/s]
 85%|########5 | 319/375 [00:03<00:00, 105.20it/s]
 88%|########8 | 330/375 [00:03<00:00, 104.59it/s]
 91%|######### | 341/375 [00:03<00:00, 104.09it/s]
 94%|#########3| 352/375 [00:03<00:00, 104.51it/s]
 97%|#########6| 363/375 [00:03<00:00, 104.93it/s]
100%|#########9| 374/375 [00:03<00:00, 105.18it/s]
100%|##########| 375/375 [00:03<00:00, 101.47it/s]
[[ 0.12 -0.19 -0.53]
 [-0.26  0.04  0.61]
 [ 0.12  0.1  -0.38]
 ...
 [-0.01  0.05 -0.36]
 [ 0.06  0.03  0.09]
 [ 0.04  0.14 -0.39]]
base value: 0.6042417816207103

  0%|          | 0/375 [00:00<?, ?it/s]
  3%|2         | 11/375 [00:00<00:03, 106.25it/s]
  6%|5         | 22/375 [00:00<00:03, 105.00it/s]
  9%|8         | 33/375 [00:00<00:03, 105.74it/s]
 12%|#1        | 44/375 [00:00<00:03, 105.94it/s]
 15%|#4        | 55/375 [00:00<00:03, 104.78it/s]
 18%|#7        | 66/375 [00:00<00:02, 104.96it/s]
 21%|##        | 77/375 [00:00<00:02, 104.63it/s]
 23%|##3       | 88/375 [00:00<00:02, 105.25it/s]
 26%|##6       | 99/375 [00:00<00:02, 104.57it/s]
 29%|##9       | 110/375 [00:01<00:02, 104.69it/s]
 32%|###2      | 121/375 [00:01<00:02, 103.71it/s]
 35%|###5      | 132/375 [00:01<00:02, 103.72it/s]
 38%|###8      | 143/375 [00:01<00:02, 103.79it/s]
 41%|####1     | 154/375 [00:01<00:02, 104.32it/s]
 44%|####4     | 165/375 [00:01<00:02, 104.60it/s]
 47%|####6     | 176/375 [00:01<00:01, 104.40it/s]
 50%|####9     | 187/375 [00:01<00:01, 104.47it/s]
 53%|#####2    | 198/375 [00:01<00:01, 105.03it/s]
 56%|#####5    | 209/375 [00:01<00:01, 105.05it/s]
 59%|#####8    | 220/375 [00:02<00:01, 105.71it/s]
 62%|######1   | 231/375 [00:02<00:01, 102.83it/s]
 65%|######4   | 242/375 [00:02<00:01, 102.59it/s]
 67%|######7   | 253/375 [00:02<00:01, 103.62it/s]
 70%|#######   | 264/375 [00:02<00:01, 101.91it/s]
 73%|#######3  | 275/375 [00:02<00:00, 100.01it/s]
 76%|#######6  | 286/375 [00:02<00:00, 99.77it/s]
 79%|#######9  | 297/375 [00:02<00:00, 101.13it/s]
 82%|########2 | 308/375 [00:02<00:00, 101.32it/s]
 85%|########5 | 319/375 [00:03<00:00, 101.71it/s]
 88%|########8 | 330/375 [00:03<00:00, 101.81it/s]
 91%|######### | 341/375 [00:03<00:00, 102.53it/s]
 94%|#########3| 352/375 [00:03<00:00, 102.66it/s]
 97%|#########6| 363/375 [00:03<00:00, 103.10it/s]
100%|#########9| 374/375 [00:03<00:00, 103.42it/s]
100%|##########| 375/375 [00:03<00:00, 103.50it/s]

--------------------------------------------------------------------------------
Classifier: DecisionTreeClassifier(random_state=0)
Kernel type: <class 'shap.explainers._kernel.Kernel'>

  0%|          | 0/375 [00:00<?, ?it/s]
  3%|2         | 11/375 [00:00<00:03, 103.22it/s]
  6%|5         | 22/375 [00:00<00:03, 104.55it/s]
  9%|8         | 33/375 [00:00<00:03, 105.37it/s]
 12%|#1        | 44/375 [00:00<00:03, 104.61it/s]
 15%|#4        | 55/375 [00:00<00:03, 100.55it/s]
 18%|#7        | 66/375 [00:00<00:03, 99.73it/s]
 21%|##        | 77/375 [00:00<00:02, 101.32it/s]
 23%|##3       | 88/375 [00:00<00:02, 101.62it/s]
 26%|##6       | 99/375 [00:00<00:02, 101.57it/s]
 29%|##9       | 110/375 [00:01<00:02, 101.99it/s]
 32%|###2      | 121/375 [00:01<00:02, 102.61it/s]
 35%|###5      | 132/375 [00:01<00:02, 103.42it/s]
 38%|###8      | 143/375 [00:01<00:02, 103.96it/s]
 41%|####1     | 154/375 [00:01<00:02, 103.69it/s]
 44%|####4     | 165/375 [00:01<00:02, 103.95it/s]
 47%|####6     | 176/375 [00:01<00:01, 103.94it/s]
 50%|####9     | 187/375 [00:01<00:01, 104.03it/s]
 53%|#####2    | 198/375 [00:01<00:01, 103.87it/s]
 56%|#####5    | 209/375 [00:02<00:01, 103.48it/s]
 59%|#####8    | 220/375 [00:02<00:01, 103.13it/s]
 62%|######1   | 231/375 [00:02<00:01, 102.65it/s]
 65%|######4   | 242/375 [00:02<00:01, 101.36it/s]
 67%|######7   | 253/375 [00:02<00:01, 99.59it/s]
 70%|#######   | 263/375 [00:02<00:01, 98.80it/s]
 73%|#######2  | 273/375 [00:02<00:01, 98.60it/s]
 75%|#######5  | 283/375 [00:02<00:00, 98.08it/s]
 78%|#######8  | 293/375 [00:02<00:00, 96.87it/s]
 81%|########  | 303/375 [00:02<00:00, 96.76it/s]
 83%|########3 | 313/375 [00:03<00:00, 97.00it/s]
 86%|########6 | 323/375 [00:03<00:00, 95.70it/s]
 89%|########8 | 333/375 [00:03<00:00, 94.91it/s]
 91%|#########1| 343/375 [00:03<00:00, 95.58it/s]
 94%|#########4| 353/375 [00:03<00:00, 93.64it/s]
 97%|#########6| 363/375 [00:03<00:00, 94.33it/s]
 99%|#########9| 373/375 [00:03<00:00, 95.38it/s]
100%|##########| 375/375 [00:03<00:00, 100.01it/s]
[[ 0.02 -0.02 -0.59]
 [-0.01  0.09  0.34]
 [ 0.02  0.43 -0.04]
 ...
 [ 0.02 -0.12 -0.49]
 [-0.36 -0.08 -0.15]
 [ 0.02  0.07 -0.68]]
base value: 0.5900000000000001

  0%|          | 0/375 [00:00<?, ?it/s]
  3%|2         | 10/375 [00:00<00:03, 99.51it/s]
  5%|5         | 20/375 [00:00<00:03, 98.52it/s]
  8%|8         | 31/375 [00:00<00:03, 99.18it/s]
 11%|#         | 41/375 [00:00<00:03, 99.47it/s]
 14%|#3        | 51/375 [00:00<00:03, 98.78it/s]
 16%|#6        | 61/375 [00:00<00:03, 98.30it/s]
 19%|#8        | 71/375 [00:00<00:03, 97.05it/s]
 22%|##1       | 81/375 [00:00<00:03, 97.25it/s]
 24%|##4       | 91/375 [00:00<00:02, 97.01it/s]
 27%|##7       | 102/375 [00:01<00:02, 98.06it/s]
 30%|###       | 113/375 [00:01<00:02, 99.18it/s]
 33%|###3      | 124/375 [00:01<00:02, 100.66it/s]
 36%|###6      | 135/375 [00:01<00:02, 102.04it/s]
 39%|###8      | 146/375 [00:01<00:02, 103.13it/s]
 42%|####1     | 157/375 [00:01<00:02, 104.08it/s]
 45%|####4     | 168/375 [00:01<00:01, 104.73it/s]
 48%|####7     | 179/375 [00:01<00:01, 104.42it/s]
 51%|#####     | 190/375 [00:01<00:01, 104.80it/s]
 54%|#####3    | 201/375 [00:01<00:01, 105.04it/s]
 57%|#####6    | 212/375 [00:02<00:01, 105.26it/s]
 59%|#####9    | 223/375 [00:02<00:01, 105.46it/s]
 62%|######2   | 234/375 [00:02<00:01, 105.13it/s]
 65%|######5   | 245/375 [00:02<00:01, 105.12it/s]
 68%|######8   | 256/375 [00:02<00:01, 105.47it/s]
 71%|#######1  | 267/375 [00:02<00:01, 105.63it/s]
 74%|#######4  | 278/375 [00:02<00:00, 103.97it/s]
 77%|#######7  | 289/375 [00:02<00:00, 100.02it/s]
 80%|########  | 300/375 [00:02<00:00, 99.96it/s]
 83%|########2 | 311/375 [00:03<00:00, 99.34it/s]
 86%|########5 | 322/375 [00:03<00:00, 100.14it/s]
 89%|########8 | 333/375 [00:03<00:00, 101.15it/s]
 92%|#########1| 344/375 [00:03<00:00, 101.93it/s]
 95%|#########4| 355/375 [00:03<00:00, 101.48it/s]
 98%|#########7| 366/375 [00:03<00:00, 101.63it/s]
100%|##########| 375/375 [00:03<00:00, 101.68it/s]

--------------------------------------------------------------------------------
Classifier: RandomForestClassifier(random_state=0)
Kernel type: <class 'shap.explainers._kernel.Kernel'>

  0%|          | 0/375 [00:00<?, ?it/s]
  1%|1         | 4/375 [00:00<00:10, 35.47it/s]
  2%|2         | 8/375 [00:00<00:10, 35.67it/s]
  3%|3         | 12/375 [00:00<00:10, 35.46it/s]
  4%|4         | 16/375 [00:00<00:10, 35.15it/s]
  5%|5         | 20/375 [00:00<00:10, 35.43it/s]
  6%|6         | 24/375 [00:00<00:09, 35.85it/s]
  7%|7         | 28/375 [00:00<00:09, 35.97it/s]
  9%|8         | 32/375 [00:00<00:09, 36.18it/s]
 10%|9         | 36/375 [00:01<00:09, 35.60it/s]
 11%|#         | 40/375 [00:01<00:09, 35.75it/s]
 12%|#1        | 44/375 [00:01<00:09, 35.94it/s]
 13%|#2        | 48/375 [00:01<00:09, 36.06it/s]
 14%|#3        | 52/375 [00:01<00:08, 35.94it/s]
 15%|#4        | 56/375 [00:01<00:08, 35.83it/s]
 16%|#6        | 60/375 [00:01<00:08, 36.06it/s]
 17%|#7        | 64/375 [00:01<00:08, 36.11it/s]
 18%|#8        | 68/375 [00:01<00:08, 36.16it/s]
 19%|#9        | 72/375 [00:02<00:08, 36.08it/s]
 20%|##        | 76/375 [00:02<00:08, 36.21it/s]
 21%|##1       | 80/375 [00:02<00:08, 35.81it/s]
 22%|##2       | 84/375 [00:02<00:08, 35.22it/s]
 23%|##3       | 88/375 [00:02<00:08, 34.52it/s]
 25%|##4       | 92/375 [00:02<00:08, 34.86it/s]
 26%|##5       | 96/375 [00:02<00:07, 35.22it/s]
 27%|##6       | 100/375 [00:02<00:07, 35.28it/s]
 28%|##7       | 104/375 [00:02<00:07, 35.28it/s]
 29%|##8       | 108/375 [00:03<00:07, 35.55it/s]
 30%|##9       | 112/375 [00:03<00:07, 35.69it/s]
 31%|###       | 116/375 [00:03<00:07, 35.72it/s]
 32%|###2      | 120/375 [00:03<00:07, 35.89it/s]
 33%|###3      | 124/375 [00:03<00:07, 35.76it/s]
 34%|###4      | 128/375 [00:03<00:06, 35.80it/s]
 35%|###5      | 132/375 [00:03<00:06, 35.83it/s]
 36%|###6      | 136/375 [00:03<00:06, 35.89it/s]
 37%|###7      | 140/375 [00:03<00:06, 35.22it/s]
 38%|###8      | 144/375 [00:04<00:06, 35.06it/s]
 39%|###9      | 148/375 [00:04<00:06, 35.04it/s]
 41%|####      | 152/375 [00:04<00:06, 35.23it/s]
 42%|####1     | 156/375 [00:04<00:06, 35.39it/s]
 43%|####2     | 160/375 [00:04<00:06, 35.33it/s]
 44%|####3     | 164/375 [00:04<00:05, 35.42it/s]
 45%|####4     | 168/375 [00:04<00:05, 35.51it/s]
 46%|####5     | 172/375 [00:04<00:05, 35.65it/s]
 47%|####6     | 176/375 [00:04<00:05, 35.50it/s]
 48%|####8     | 180/375 [00:05<00:05, 35.65it/s]
 49%|####9     | 184/375 [00:05<00:05, 35.62it/s]
 50%|#####     | 188/375 [00:05<00:05, 35.54it/s]
 51%|#####1    | 192/375 [00:05<00:05, 35.65it/s]
 52%|#####2    | 196/375 [00:05<00:05, 35.59it/s]
 53%|#####3    | 200/375 [00:05<00:04, 35.61it/s]
 54%|#####4    | 204/375 [00:05<00:04, 35.62it/s]
 55%|#####5    | 208/375 [00:05<00:04, 35.03it/s]
 57%|#####6    | 212/375 [00:05<00:04, 34.28it/s]
 58%|#####7    | 216/375 [00:06<00:04, 33.86it/s]
 59%|#####8    | 220/375 [00:06<00:04, 33.47it/s]
 60%|#####9    | 224/375 [00:06<00:04, 33.57it/s]
 61%|######    | 228/375 [00:06<00:04, 33.47it/s]
 62%|######1   | 232/375 [00:06<00:04, 32.98it/s]
 63%|######2   | 236/375 [00:06<00:04, 33.15it/s]
 64%|######4   | 240/375 [00:06<00:04, 33.19it/s]
 65%|######5   | 244/375 [00:06<00:03, 33.16it/s]
 66%|######6   | 248/375 [00:07<00:03, 33.14it/s]
 67%|######7   | 252/375 [00:07<00:03, 33.45it/s]
 68%|######8   | 256/375 [00:07<00:03, 33.77it/s]
 69%|######9   | 260/375 [00:07<00:03, 33.77it/s]
 70%|#######   | 264/375 [00:07<00:03, 33.77it/s]
 71%|#######1  | 268/375 [00:07<00:03, 33.71it/s]
 73%|#######2  | 272/375 [00:07<00:03, 33.69it/s]
 74%|#######3  | 276/375 [00:07<00:02, 33.60it/s]
 75%|#######4  | 280/375 [00:08<00:02, 33.75it/s]
 76%|#######5  | 284/375 [00:08<00:02, 33.77it/s]
 77%|#######6  | 288/375 [00:08<00:02, 34.13it/s]
 78%|#######7  | 292/375 [00:08<00:02, 34.74it/s]
 79%|#######8  | 296/375 [00:08<00:02, 34.99it/s]
 80%|########  | 300/375 [00:08<00:02, 35.57it/s]
 81%|########1 | 304/375 [00:08<00:01, 35.90it/s]
 82%|########2 | 308/375 [00:08<00:01, 35.89it/s]
 83%|########3 | 312/375 [00:08<00:01, 36.15it/s]
 84%|########4 | 316/375 [00:09<00:01, 35.92it/s]
 85%|########5 | 320/375 [00:09<00:01, 36.16it/s]
 86%|########6 | 324/375 [00:09<00:01, 36.31it/s]
 87%|########7 | 328/375 [00:09<00:01, 36.11it/s]
 89%|########8 | 332/375 [00:09<00:01, 35.99it/s]
 90%|########9 | 336/375 [00:09<00:01, 36.13it/s]
 91%|######### | 340/375 [00:09<00:00, 36.30it/s]
 92%|#########1| 344/375 [00:09<00:00, 36.41it/s]
 93%|#########2| 348/375 [00:09<00:00, 36.55it/s]
 94%|#########3| 352/375 [00:10<00:00, 36.00it/s]
 95%|#########4| 356/375 [00:10<00:00, 35.91it/s]
 96%|#########6| 360/375 [00:10<00:00, 36.09it/s]
 97%|#########7| 364/375 [00:10<00:00, 36.19it/s]
 98%|#########8| 368/375 [00:10<00:00, 36.13it/s]
 99%|#########9| 372/375 [00:10<00:00, 36.14it/s]
100%|##########| 375/375 [00:10<00:00, 35.25it/s]
[[-0.2  -0.04 -0.35]
 [ 0.1   0.07  0.23]
 [-0.01  0.28 -0.14]
 ...
 [-0.01 -0.02 -0.3 ]
 [-0.06 -0.15 -0.04]
 [-0.21  0.1  -0.35]]
base value: 0.5881000000000001

  0%|          | 0/375 [00:00<?, ?it/s]
  1%|1         | 4/375 [00:00<00:10, 36.96it/s]
  2%|2         | 8/375 [00:00<00:10, 36.54it/s]
  3%|3         | 12/375 [00:00<00:10, 36.23it/s]
  4%|4         | 16/375 [00:00<00:10, 35.83it/s]
  5%|5         | 20/375 [00:00<00:09, 36.10it/s]
  6%|6         | 24/375 [00:00<00:09, 36.15it/s]
  7%|7         | 28/375 [00:00<00:09, 36.23it/s]
  9%|8         | 32/375 [00:00<00:09, 36.37it/s]
 10%|9         | 36/375 [00:00<00:09, 36.36it/s]
 11%|#         | 40/375 [00:01<00:09, 36.28it/s]
 12%|#1        | 44/375 [00:01<00:09, 36.32it/s]
 13%|#2        | 48/375 [00:01<00:09, 36.17it/s]
 14%|#3        | 52/375 [00:01<00:08, 36.22it/s]
 15%|#4        | 56/375 [00:01<00:08, 36.08it/s]
 16%|#6        | 60/375 [00:01<00:08, 36.21it/s]
 17%|#7        | 64/375 [00:01<00:08, 36.15it/s]
 18%|#8        | 68/375 [00:01<00:08, 36.23it/s]
 19%|#9        | 72/375 [00:01<00:08, 36.15it/s]
 20%|##        | 76/375 [00:02<00:08, 36.31it/s]
 21%|##1       | 80/375 [00:02<00:08, 36.44it/s]
 22%|##2       | 84/375 [00:02<00:08, 36.34it/s]
 23%|##3       | 88/375 [00:02<00:07, 36.35it/s]
 25%|##4       | 92/375 [00:02<00:07, 35.96it/s]
 26%|##5       | 96/375 [00:02<00:07, 35.22it/s]
 27%|##6       | 100/375 [00:02<00:07, 34.56it/s]
 28%|##7       | 104/375 [00:02<00:07, 34.81it/s]
 29%|##8       | 108/375 [00:03<00:07, 35.15it/s]
 30%|##9       | 112/375 [00:03<00:07, 35.07it/s]
 31%|###       | 116/375 [00:03<00:07, 35.04it/s]
 32%|###2      | 120/375 [00:03<00:07, 35.26it/s]
 33%|###3      | 124/375 [00:03<00:07, 35.46it/s]
 34%|###4      | 128/375 [00:03<00:06, 35.59it/s]
 35%|###5      | 132/375 [00:03<00:07, 34.46it/s]
 36%|###6      | 136/375 [00:03<00:07, 33.25it/s]
 37%|###7      | 140/375 [00:03<00:07, 33.40it/s]
 38%|###8      | 144/375 [00:04<00:06, 33.18it/s]
 39%|###9      | 148/375 [00:04<00:06, 33.33it/s]
 41%|####      | 152/375 [00:04<00:06, 32.66it/s]
 42%|####1     | 156/375 [00:04<00:06, 31.70it/s]
 43%|####2     | 160/375 [00:04<00:06, 31.83it/s]
 44%|####3     | 164/375 [00:04<00:06, 31.63it/s]
 45%|####4     | 168/375 [00:04<00:06, 32.33it/s]
 46%|####5     | 172/375 [00:04<00:06, 33.36it/s]
 47%|####6     | 176/375 [00:05<00:05, 34.13it/s]
 48%|####8     | 180/375 [00:05<00:05, 34.65it/s]
 49%|####9     | 184/375 [00:05<00:05, 34.55it/s]
 50%|#####     | 188/375 [00:05<00:05, 34.46it/s]
 51%|#####1    | 192/375 [00:05<00:05, 34.79it/s]
 52%|#####2    | 196/375 [00:05<00:05, 35.23it/s]
 53%|#####3    | 200/375 [00:05<00:04, 35.53it/s]
 54%|#####4    | 204/375 [00:05<00:04, 35.27it/s]
 55%|#####5    | 208/375 [00:05<00:04, 35.27it/s]
 57%|#####6    | 212/375 [00:06<00:04, 35.35it/s]
 58%|#####7    | 216/375 [00:06<00:04, 34.62it/s]
 59%|#####8    | 220/375 [00:06<00:04, 34.19it/s]
 60%|#####9    | 224/375 [00:06<00:04, 33.98it/s]
 61%|######    | 228/375 [00:06<00:04, 33.95it/s]
 62%|######1   | 232/375 [00:06<00:04, 33.83it/s]
 63%|######2   | 236/375 [00:06<00:04, 33.47it/s]
 64%|######4   | 240/375 [00:06<00:04, 33.47it/s]
 65%|######5   | 244/375 [00:07<00:03, 33.60it/s]
 66%|######6   | 248/375 [00:07<00:03, 33.60it/s]
 67%|######7   | 252/375 [00:07<00:03, 33.60it/s]
 68%|######8   | 256/375 [00:07<00:03, 33.46it/s]
 69%|######9   | 260/375 [00:07<00:03, 33.65it/s]
 70%|#######   | 264/375 [00:07<00:03, 33.83it/s]
 71%|#######1  | 268/375 [00:07<00:03, 33.82it/s]
 73%|#######2  | 272/375 [00:07<00:03, 34.09it/s]
 74%|#######3  | 276/375 [00:07<00:02, 34.33it/s]
 75%|#######4  | 280/375 [00:08<00:02, 33.89it/s]
 76%|#######5  | 284/375 [00:08<00:02, 34.11it/s]
 77%|#######6  | 288/375 [00:08<00:02, 34.14it/s]
 78%|#######7  | 292/375 [00:08<00:02, 34.00it/s]
 79%|#######8  | 296/375 [00:08<00:02, 33.76it/s]
 80%|########  | 300/375 [00:08<00:02, 33.96it/s]
 81%|########1 | 304/375 [00:08<00:02, 34.37it/s]
 82%|########2 | 308/375 [00:08<00:01, 34.96it/s]
 83%|########3 | 312/375 [00:08<00:01, 35.48it/s]
 84%|########4 | 316/375 [00:09<00:01, 35.88it/s]
 85%|########5 | 320/375 [00:09<00:01, 36.12it/s]
 86%|########6 | 324/375 [00:09<00:01, 35.84it/s]
 87%|########7 | 328/375 [00:09<00:01, 35.98it/s]
 89%|########8 | 332/375 [00:09<00:01, 36.12it/s]
 90%|########9 | 336/375 [00:09<00:01, 36.28it/s]
 91%|######### | 340/375 [00:09<00:00, 36.31it/s]
 92%|#########1| 344/375 [00:09<00:00, 36.37it/s]
 93%|#########2| 348/375 [00:09<00:00, 36.44it/s]
 94%|#########3| 352/375 [00:10<00:00, 36.61it/s]
 95%|#########4| 356/375 [00:10<00:00, 36.48it/s]
 96%|#########6| 360/375 [00:10<00:00, 36.29it/s]
 97%|#########7| 364/375 [00:10<00:00, 35.95it/s]
 98%|#########8| 368/375 [00:10<00:00, 36.02it/s]
 99%|#########9| 372/375 [00:10<00:00, 36.19it/s]
100%|##########| 375/375 [00:10<00:00, 34.94it/s]

--------------------------------------------------------------------------------
Classifier: XGBClassifier(base_score=None, booster=None, callbacks=None,
              colsample_bylevel=None, colsample_bynode=None,
              colsample_bytree=None, early_stopping_rounds=None,
              enable_categorical=False, eta=0.05, eval_metric=None,
              feature_types=None, gamma=0.2, gpu_id=None, grow_policy=None,
              importance_type=None, interaction_constraints=None,
              learning_rate=None, max_bin=None, max_cat_threshold=None,
              max_cat_to_onehot=None, max_delta_step=None, max_depth=4,
              max_leaves=None, min_child_weight=0.005, missing=nan,
              monotone_constraints=None, n_estimators=100, n_jobs=None,
              num_parallel_tree=None, predictor=None, ...)
Kernel type: <class 'shap.explainers._tree.Tree'>
[[-0.09 -0.58 -4.2 ]
 [-0.57  0.93  3.57]
 [ 0.33  2.81 -2.97]
 ...
 [ 0.78 -0.04 -2.36]
 [ 0.25 -0.04  0.63]
 [ 0.22  1.57 -3.67]]
base value: 0.35041043226607144

--------------------------------------------------------------------------------
Classifier: MLPClassifier()
Kernel type: <class 'shap.explainers._kernel.Kernel'>

  0%|          | 0/375 [00:00<?, ?it/s]
  3%|2         | 10/375 [00:00<00:03, 95.52it/s]
  5%|5         | 20/375 [00:00<00:03, 97.31it/s]
  8%|8         | 30/375 [00:00<00:03, 96.65it/s]
 11%|#         | 40/375 [00:00<00:03, 96.73it/s]
 13%|#3        | 50/375 [00:00<00:03, 96.40it/s]
 16%|#6        | 60/375 [00:00<00:03, 96.01it/s]
 19%|#8        | 70/375 [00:00<00:03, 96.25it/s]
 21%|##1       | 80/375 [00:00<00:03, 95.35it/s]
 24%|##4       | 90/375 [00:00<00:02, 95.70it/s]
 27%|##6       | 100/375 [00:01<00:02, 94.51it/s]
 29%|##9       | 110/375 [00:01<00:02, 92.85it/s]
 32%|###2      | 120/375 [00:01<00:02, 93.83it/s]
 35%|###4      | 130/375 [00:01<00:02, 94.67it/s]
 37%|###7      | 140/375 [00:01<00:02, 94.84it/s]
 40%|####      | 150/375 [00:01<00:02, 94.52it/s]
 43%|####2     | 160/375 [00:01<00:02, 95.32it/s]
 45%|####5     | 170/375 [00:01<00:02, 95.89it/s]
 48%|####8     | 180/375 [00:01<00:02, 94.36it/s]
 51%|#####     | 190/375 [00:01<00:01, 95.04it/s]
 53%|#####3    | 200/375 [00:02<00:01, 95.42it/s]
 56%|#####6    | 210/375 [00:02<00:01, 96.03it/s]
 59%|#####8    | 220/375 [00:02<00:01, 96.59it/s]
 61%|######1   | 230/375 [00:02<00:01, 96.68it/s]
 64%|######4   | 240/375 [00:02<00:01, 94.76it/s]
 67%|######6   | 250/375 [00:02<00:01, 94.04it/s]
 69%|######9   | 260/375 [00:02<00:01, 93.58it/s]
 72%|#######2  | 270/375 [00:02<00:01, 91.96it/s]
 75%|#######4  | 280/375 [00:02<00:01, 89.34it/s]
 77%|#######7  | 289/375 [00:03<00:00, 89.26it/s]
 80%|#######9  | 299/375 [00:03<00:00, 89.61it/s]
 82%|########2 | 309/375 [00:03<00:00, 90.94it/s]
 85%|########5 | 319/375 [00:03<00:00, 91.90it/s]
 88%|########7 | 329/375 [00:03<00:00, 91.91it/s]
 90%|######### | 339/375 [00:03<00:00, 92.06it/s]
 93%|#########3| 349/375 [00:03<00:00, 89.55it/s]
 96%|#########5| 359/375 [00:03<00:00, 90.60it/s]
 98%|#########8| 369/375 [00:03<00:00, 91.40it/s]
100%|##########| 375/375 [00:04<00:00, 93.62it/s]
[[ 0.02  0.44 -0.13]
 [-0.04 -0.16  0.33]
 [ 0.03 -0.13 -0.16]
 ...
 [ 0.01 -0.08 -0.1 ]
 [-0.01 -0.01  0.06]
 [ 0.01 -0.21 -0.14]]
base value: 0.5657158421944968

  0%|          | 0/375 [00:00<?, ?it/s]
  3%|2         | 10/375 [00:00<00:04, 90.68it/s]
  5%|5         | 20/375 [00:00<00:04, 86.58it/s]
  8%|7         | 29/375 [00:00<00:04, 83.49it/s]
 10%|#         | 38/375 [00:00<00:03, 85.53it/s]
 13%|#2        | 47/375 [00:00<00:03, 86.17it/s]
 15%|#4        | 56/375 [00:00<00:03, 85.91it/s]
 18%|#7        | 66/375 [00:00<00:03, 87.57it/s]
 20%|##        | 75/375 [00:00<00:03, 86.79it/s]
 23%|##2       | 85/375 [00:00<00:03, 88.18it/s]
 25%|##5       | 94/375 [00:01<00:03, 88.09it/s]
 28%|##7       | 104/375 [00:01<00:03, 89.21it/s]
 30%|###       | 114/375 [00:01<00:02, 89.55it/s]
 33%|###3      | 124/375 [00:01<00:02, 89.93it/s]
 35%|###5      | 133/375 [00:01<00:02, 89.88it/s]
 38%|###7      | 142/375 [00:01<00:02, 89.14it/s]
 40%|####      | 151/375 [00:01<00:02, 88.40it/s]
 43%|####2     | 161/375 [00:01<00:02, 89.87it/s]
 45%|####5     | 170/375 [00:01<00:02, 88.96it/s]
 48%|####7     | 179/375 [00:02<00:02, 88.11it/s]
 50%|#####     | 188/375 [00:02<00:02, 87.78it/s]
 53%|#####2    | 198/375 [00:02<00:02, 88.46it/s]
 55%|#####5    | 207/375 [00:02<00:01, 88.82it/s]
 58%|#####7    | 216/375 [00:02<00:01, 88.90it/s]
 60%|######    | 225/375 [00:02<00:01, 87.16it/s]
 62%|######2   | 234/375 [00:02<00:01, 85.47it/s]
 65%|######4   | 243/375 [00:02<00:01, 84.41it/s]
 67%|######7   | 253/375 [00:02<00:01, 86.21it/s]
 70%|######9   | 262/375 [00:02<00:01, 86.49it/s]
 72%|#######2  | 271/375 [00:03<00:01, 87.08it/s]
 75%|#######4  | 280/375 [00:03<00:01, 85.60it/s]
 77%|#######7  | 289/375 [00:03<00:01, 85.07it/s]
 79%|#######9  | 298/375 [00:03<00:00, 85.91it/s]
 82%|########1 | 307/375 [00:03<00:00, 86.67it/s]
 84%|########4 | 316/375 [00:03<00:00, 87.28it/s]
 87%|########6 | 325/375 [00:03<00:00, 87.80it/s]
 89%|########9 | 334/375 [00:03<00:00, 87.26it/s]
 91%|#########1| 343/375 [00:03<00:00, 87.26it/s]
 94%|#########3| 352/375 [00:04<00:00, 87.35it/s]
 96%|#########6| 361/375 [00:04<00:00, 87.14it/s]
 99%|#########8| 370/375 [00:04<00:00, 87.64it/s]
100%|##########| 375/375 [00:04<00:00, 87.48it/s]

--------------------------------------------------------------------------------
Classifier: SVC(probability=True)
Kernel type: <class 'shap.explainers._kernel.Kernel'>

  0%|          | 0/375 [00:00<?, ?it/s]
  2%|1         | 6/375 [00:00<00:06, 55.97it/s]
  3%|3         | 12/375 [00:00<00:06, 55.86it/s]
  5%|4         | 18/375 [00:00<00:06, 55.19it/s]
  6%|6         | 24/375 [00:00<00:06, 55.41it/s]
  8%|8         | 30/375 [00:00<00:06, 55.53it/s]
 10%|9         | 36/375 [00:00<00:06, 56.03it/s]
 11%|#1        | 42/375 [00:00<00:05, 56.54it/s]
 13%|#2        | 48/375 [00:00<00:05, 57.19it/s]
 14%|#4        | 54/375 [00:00<00:05, 57.71it/s]
 16%|#6        | 60/375 [00:01<00:05, 58.17it/s]
 18%|#7        | 66/375 [00:01<00:05, 58.42it/s]
 19%|#9        | 72/375 [00:01<00:05, 58.60it/s]
 21%|##        | 78/375 [00:01<00:05, 58.73it/s]
 22%|##2       | 84/375 [00:01<00:04, 58.87it/s]
 24%|##4       | 90/375 [00:01<00:04, 58.90it/s]
 26%|##5       | 96/375 [00:01<00:04, 58.87it/s]
 27%|##7       | 102/375 [00:01<00:04, 58.93it/s]
 29%|##8       | 108/375 [00:01<00:04, 58.93it/s]
 30%|###       | 114/375 [00:01<00:04, 58.93it/s]
 32%|###2      | 120/375 [00:02<00:04, 58.96it/s]
 34%|###3      | 126/375 [00:02<00:04, 59.02it/s]
 35%|###5      | 132/375 [00:02<00:04, 58.96it/s]
 37%|###6      | 138/375 [00:02<00:04, 59.04it/s]
 39%|###8      | 145/375 [00:02<00:03, 60.84it/s]
 41%|####      | 152/375 [00:02<00:03, 62.81it/s]
 42%|####2     | 159/375 [00:02<00:03, 63.93it/s]
 44%|####4     | 166/375 [00:02<00:03, 64.94it/s]
 46%|####6     | 173/375 [00:02<00:03, 65.47it/s]
 48%|####8     | 180/375 [00:03<00:03, 64.45it/s]
 50%|####9     | 187/375 [00:03<00:02, 63.56it/s]
 52%|#####1    | 194/375 [00:03<00:02, 63.25it/s]
 54%|#####3    | 201/375 [00:03<00:02, 63.56it/s]
 55%|#####5    | 208/375 [00:03<00:02, 63.80it/s]
 57%|#####7    | 215/375 [00:03<00:02, 64.11it/s]
 59%|#####9    | 222/375 [00:03<00:02, 64.82it/s]
 61%|######1   | 229/375 [00:03<00:02, 64.87it/s]
 63%|######2   | 236/375 [00:03<00:02, 64.85it/s]
 65%|######4   | 243/375 [00:03<00:02, 65.07it/s]
 67%|######6   | 250/375 [00:04<00:01, 65.51it/s]
 69%|######8   | 257/375 [00:04<00:01, 65.42it/s]
 70%|#######   | 264/375 [00:04<00:01, 65.26it/s]
 72%|#######2  | 271/375 [00:04<00:01, 65.26it/s]
 74%|#######4  | 278/375 [00:04<00:01, 65.41it/s]
 76%|#######6  | 285/375 [00:04<00:01, 65.22it/s]
 78%|#######7  | 292/375 [00:04<00:01, 63.76it/s]
 80%|#######9  | 299/375 [00:04<00:01, 63.94it/s]
 82%|########1 | 306/375 [00:04<00:01, 64.57it/s]
 83%|########3 | 313/375 [00:05<00:00, 65.20it/s]
 85%|########5 | 320/375 [00:05<00:00, 65.35it/s]
 87%|########7 | 327/375 [00:05<00:00, 64.92it/s]
 89%|########9 | 334/375 [00:05<00:00, 64.77it/s]
 91%|######### | 341/375 [00:05<00:00, 65.28it/s]
 93%|#########2| 348/375 [00:05<00:00, 65.72it/s]
 95%|#########4| 355/375 [00:05<00:00, 65.76it/s]
 97%|#########6| 362/375 [00:05<00:00, 65.75it/s]
 98%|#########8| 369/375 [00:05<00:00, 65.88it/s]
100%|##########| 375/375 [00:06<00:00, 62.32it/s]
[[-0.   -0.13 -0.46]
 [ 0.    0.04  0.35]
 [-0.    0.05 -0.45]
 ...
 [-0.    0.05 -0.27]
 [ 0.    0.02  0.21]
 [-0.    0.11 -0.37]]
base value: 0.6015391641094724

  0%|          | 0/375 [00:00<?, ?it/s]
  2%|1         | 7/375 [00:00<00:05, 64.81it/s]
  4%|3         | 14/375 [00:00<00:05, 64.53it/s]
  6%|5         | 21/375 [00:00<00:05, 64.64it/s]
  7%|7         | 28/375 [00:00<00:05, 64.47it/s]
  9%|9         | 35/375 [00:00<00:05, 63.44it/s]
 11%|#1        | 42/375 [00:00<00:05, 62.15it/s]
 13%|#3        | 49/375 [00:00<00:05, 61.70it/s]
 15%|#4        | 56/375 [00:00<00:05, 61.11it/s]
 17%|#6        | 63/375 [00:01<00:05, 61.14it/s]
 19%|#8        | 70/375 [00:01<00:05, 60.45it/s]
 21%|##        | 77/375 [00:01<00:04, 59.79it/s]
 22%|##2       | 84/375 [00:01<00:04, 60.34it/s]
 24%|##4       | 91/375 [00:01<00:04, 60.31it/s]
 26%|##6       | 98/375 [00:01<00:04, 60.67it/s]
 28%|##8       | 105/375 [00:01<00:04, 60.75it/s]
 30%|##9       | 112/375 [00:01<00:04, 60.74it/s]
 32%|###1      | 119/375 [00:01<00:04, 61.26it/s]
 34%|###3      | 126/375 [00:02<00:04, 61.43it/s]
 35%|###5      | 133/375 [00:02<00:03, 61.58it/s]
 37%|###7      | 140/375 [00:02<00:03, 61.89it/s]
 39%|###9      | 147/375 [00:02<00:03, 61.95it/s]
 41%|####1     | 154/375 [00:02<00:03, 62.18it/s]
 43%|####2     | 161/375 [00:02<00:03, 61.65it/s]
 45%|####4     | 168/375 [00:02<00:03, 61.87it/s]
 47%|####6     | 175/375 [00:02<00:03, 61.74it/s]
 49%|####8     | 182/375 [00:02<00:03, 62.36it/s]
 50%|#####     | 189/375 [00:03<00:02, 63.34it/s]
 52%|#####2    | 196/375 [00:03<00:02, 64.26it/s]
 54%|#####4    | 203/375 [00:03<00:02, 64.41it/s]
 56%|#####6    | 210/375 [00:03<00:02, 65.00it/s]
 58%|#####7    | 217/375 [00:03<00:02, 65.10it/s]
 60%|#####9    | 224/375 [00:03<00:02, 65.27it/s]
 62%|######1   | 231/375 [00:03<00:02, 65.42it/s]
 63%|######3   | 238/375 [00:03<00:02, 65.89it/s]
 65%|######5   | 245/375 [00:03<00:01, 65.82it/s]
 67%|######7   | 252/375 [00:04<00:01, 65.93it/s]
 69%|######9   | 259/375 [00:04<00:01, 66.18it/s]
 71%|#######   | 266/375 [00:04<00:01, 65.90it/s]
 73%|#######2  | 273/375 [00:04<00:01, 65.77it/s]
 75%|#######4  | 280/375 [00:04<00:01, 66.13it/s]
 77%|#######6  | 287/375 [00:04<00:01, 66.00it/s]
 78%|#######8  | 294/375 [00:04<00:01, 66.06it/s]
 80%|########  | 301/375 [00:04<00:01, 66.14it/s]
 82%|########2 | 308/375 [00:04<00:01, 66.52it/s]
 84%|########4 | 315/375 [00:04<00:00, 66.62it/s]
 86%|########5 | 322/375 [00:05<00:00, 66.61it/s]
 88%|########7 | 329/375 [00:05<00:00, 66.45it/s]
 90%|########9 | 336/375 [00:05<00:00, 66.49it/s]
 91%|#########1| 343/375 [00:05<00:00, 66.25it/s]
 93%|#########3| 350/375 [00:05<00:00, 66.22it/s]
 95%|#########5| 357/375 [00:05<00:00, 66.23it/s]
 97%|#########7| 364/375 [00:05<00:00, 66.15it/s]
 99%|#########8| 371/375 [00:05<00:00, 66.25it/s]
100%|##########| 375/375 [00:05<00:00, 63.92it/s]

--------------------------------------------------------------------------------
Classifier: ExtraTreesClassifier()
Kernel type: <class 'shap.explainers._kernel.Kernel'>

  0%|          | 0/375 [00:00<?, ?it/s]
  1%|1         | 4/375 [00:00<00:10, 35.13it/s]
  2%|2         | 8/375 [00:00<00:10, 34.48it/s]
  3%|3         | 12/375 [00:00<00:10, 34.62it/s]
  4%|4         | 16/375 [00:00<00:10, 34.78it/s]
  5%|5         | 20/375 [00:00<00:10, 34.69it/s]
  6%|6         | 24/375 [00:00<00:10, 34.90it/s]
  7%|7         | 28/375 [00:00<00:09, 34.82it/s]
  9%|8         | 32/375 [00:00<00:09, 35.22it/s]
 10%|9         | 36/375 [00:01<00:09, 35.12it/s]
 11%|#         | 40/375 [00:01<00:09, 35.18it/s]
 12%|#1        | 44/375 [00:01<00:09, 35.08it/s]
 13%|#2        | 48/375 [00:01<00:09, 35.08it/s]
 14%|#3        | 52/375 [00:01<00:09, 35.02it/s]
 15%|#4        | 56/375 [00:01<00:09, 35.07it/s]
 16%|#6        | 60/375 [00:01<00:08, 35.13it/s]
 17%|#7        | 64/375 [00:01<00:08, 34.97it/s]
 18%|#8        | 68/375 [00:01<00:08, 34.73it/s]
 19%|#9        | 72/375 [00:02<00:09, 33.39it/s]
 20%|##        | 76/375 [00:02<00:09, 32.46it/s]
 21%|##1       | 80/375 [00:02<00:08, 32.83it/s]
 22%|##2       | 84/375 [00:02<00:08, 33.38it/s]
 23%|##3       | 88/375 [00:02<00:08, 33.70it/s]
 25%|##4       | 92/375 [00:02<00:08, 33.99it/s]
 26%|##5       | 96/375 [00:02<00:08, 34.03it/s]
 27%|##6       | 100/375 [00:02<00:08, 34.27it/s]
 28%|##7       | 104/375 [00:03<00:07, 34.34it/s]
 29%|##8       | 108/375 [00:03<00:07, 34.48it/s]
 30%|##9       | 112/375 [00:03<00:07, 34.21it/s]
 31%|###       | 116/375 [00:03<00:07, 33.87it/s]
 32%|###2      | 120/375 [00:03<00:07, 34.20it/s]
 33%|###3      | 124/375 [00:03<00:07, 34.63it/s]
 34%|###4      | 128/375 [00:03<00:07, 33.94it/s]
 35%|###5      | 132/375 [00:03<00:07, 34.10it/s]
 36%|###6      | 136/375 [00:03<00:07, 34.11it/s]
 37%|###7      | 140/375 [00:04<00:06, 34.43it/s]
 38%|###8      | 144/375 [00:04<00:06, 34.57it/s]
 39%|###9      | 148/375 [00:04<00:06, 34.11it/s]
 41%|####      | 152/375 [00:04<00:06, 34.37it/s]
 42%|####1     | 156/375 [00:04<00:06, 34.48it/s]
 43%|####2     | 160/375 [00:04<00:06, 34.51it/s]
 44%|####3     | 164/375 [00:04<00:06, 34.59it/s]
 45%|####4     | 168/375 [00:04<00:06, 34.34it/s]
 46%|####5     | 172/375 [00:05<00:05, 34.34it/s]
 47%|####6     | 176/375 [00:05<00:05, 34.35it/s]
 48%|####8     | 180/375 [00:05<00:05, 34.24it/s]
 49%|####9     | 184/375 [00:05<00:05, 34.18it/s]
 50%|#####     | 188/375 [00:05<00:05, 33.88it/s]
 51%|#####1    | 192/375 [00:05<00:05, 33.30it/s]
 52%|#####2    | 196/375 [00:05<00:05, 33.01it/s]
 53%|#####3    | 200/375 [00:05<00:05, 32.90it/s]
 54%|#####4    | 204/375 [00:05<00:05, 32.72it/s]
 55%|#####5    | 208/375 [00:06<00:05, 32.71it/s]
 57%|#####6    | 212/375 [00:06<00:05, 32.32it/s]
 58%|#####7    | 216/375 [00:06<00:04, 32.38it/s]
 59%|#####8    | 220/375 [00:06<00:04, 31.92it/s]
 60%|#####9    | 224/375 [00:06<00:04, 32.24it/s]
 61%|######    | 228/375 [00:06<00:04, 31.91it/s]
 62%|######1   | 232/375 [00:06<00:04, 31.96it/s]
 63%|######2   | 236/375 [00:06<00:04, 32.04it/s]
 64%|######4   | 240/375 [00:07<00:04, 32.30it/s]
 65%|######5   | 244/375 [00:07<00:04, 32.39it/s]
 66%|######6   | 248/375 [00:07<00:03, 32.56it/s]
 67%|######7   | 252/375 [00:07<00:03, 32.89it/s]
 68%|######8   | 256/375 [00:07<00:03, 32.84it/s]
 69%|######9   | 260/375 [00:07<00:03, 33.12it/s]
 70%|#######   | 264/375 [00:07<00:03, 32.56it/s]
 71%|#######1  | 268/375 [00:07<00:03, 32.82it/s]
 73%|#######2  | 272/375 [00:08<00:03, 33.47it/s]
 74%|#######3  | 276/375 [00:08<00:02, 33.71it/s]
 75%|#######4  | 280/375 [00:08<00:02, 32.66it/s]
 76%|#######5  | 284/375 [00:08<00:02, 32.75it/s]
 77%|#######6  | 288/375 [00:08<00:02, 32.64it/s]
 78%|#######7  | 292/375 [00:08<00:02, 32.83it/s]
 79%|#######8  | 296/375 [00:08<00:02, 32.80it/s]
 80%|########  | 300/375 [00:08<00:02, 32.99it/s]
 81%|########1 | 304/375 [00:09<00:02, 32.94it/s]
 82%|########2 | 308/375 [00:09<00:02, 33.17it/s]
 83%|########3 | 312/375 [00:09<00:01, 33.35it/s]
 84%|########4 | 316/375 [00:09<00:01, 33.40it/s]
 85%|########5 | 320/375 [00:09<00:01, 33.69it/s]
 86%|########6 | 324/375 [00:09<00:01, 33.76it/s]
 87%|########7 | 328/375 [00:09<00:01, 33.79it/s]
 89%|########8 | 332/375 [00:09<00:01, 33.92it/s]
 90%|########9 | 336/375 [00:09<00:01, 33.63it/s]
 91%|######### | 340/375 [00:10<00:01, 33.76it/s]
 92%|#########1| 344/375 [00:10<00:00, 33.92it/s]
 93%|#########2| 348/375 [00:10<00:00, 34.33it/s]
 94%|#########3| 352/375 [00:10<00:00, 34.65it/s]
 95%|#########4| 356/375 [00:10<00:00, 34.79it/s]
 96%|#########6| 360/375 [00:10<00:00, 34.88it/s]
 97%|#########7| 364/375 [00:10<00:00, 34.92it/s]
 98%|#########8| 368/375 [00:10<00:00, 35.07it/s]
 99%|#########9| 372/375 [00:11<00:00, 35.10it/s]
100%|##########| 375/375 [00:11<00:00, 33.80it/s]
[[-0.21 -0.09 -0.29]
 [ 0.14  0.04  0.23]
 [ 0.12  0.34 -0.05]
 ...
 [-0.15 -0.12 -0.33]
 [-0.15 -0.22 -0.22]
 [-0.24  0.01 -0.36]]
base value: 0.5900000000000001

  0%|          | 0/375 [00:00<?, ?it/s]
  1%|1         | 4/375 [00:00<00:10, 35.36it/s]
  2%|2         | 8/375 [00:00<00:10, 35.07it/s]
  3%|3         | 12/375 [00:00<00:10, 34.74it/s]
  4%|4         | 16/375 [00:00<00:10, 34.99it/s]
  5%|5         | 20/375 [00:00<00:10, 34.92it/s]
  6%|6         | 24/375 [00:00<00:10, 34.96it/s]
  7%|7         | 28/375 [00:00<00:09, 34.88it/s]
  9%|8         | 32/375 [00:00<00:09, 35.06it/s]
 10%|9         | 36/375 [00:01<00:09, 34.85it/s]
 11%|#         | 40/375 [00:01<00:09, 34.63it/s]
 12%|#1        | 44/375 [00:01<00:09, 34.93it/s]
 13%|#2        | 48/375 [00:01<00:09, 34.94it/s]
 14%|#3        | 52/375 [00:01<00:09, 34.94it/s]
 15%|#4        | 56/375 [00:01<00:09, 34.92it/s]
 16%|#6        | 60/375 [00:01<00:08, 35.14it/s]
 17%|#7        | 64/375 [00:01<00:08, 34.81it/s]
 18%|#8        | 68/375 [00:01<00:09, 33.92it/s]
 19%|#9        | 72/375 [00:02<00:09, 33.48it/s]
 20%|##        | 76/375 [00:02<00:09, 32.86it/s]
 21%|##1       | 80/375 [00:02<00:08, 33.01it/s]
 22%|##2       | 84/375 [00:02<00:08, 33.32it/s]
 23%|##3       | 88/375 [00:02<00:08, 33.87it/s]
 25%|##4       | 92/375 [00:02<00:08, 33.51it/s]
 26%|##5       | 96/375 [00:02<00:08, 33.71it/s]
 27%|##6       | 100/375 [00:02<00:08, 33.95it/s]
 28%|##7       | 104/375 [00:03<00:07, 34.08it/s]
 29%|##8       | 108/375 [00:03<00:07, 33.99it/s]
 30%|##9       | 112/375 [00:03<00:07, 34.09it/s]
 31%|###       | 116/375 [00:03<00:07, 34.32it/s]
 32%|###2      | 120/375 [00:03<00:07, 34.50it/s]
 33%|###3      | 124/375 [00:03<00:07, 33.81it/s]
 34%|###4      | 128/375 [00:03<00:07, 34.07it/s]
 35%|###5      | 132/375 [00:03<00:07, 34.15it/s]
 36%|###6      | 136/375 [00:03<00:06, 34.34it/s]
 37%|###7      | 140/375 [00:04<00:06, 33.75it/s]
 38%|###8      | 144/375 [00:04<00:06, 33.54it/s]
 39%|###9      | 148/375 [00:04<00:06, 33.62it/s]
 41%|####      | 152/375 [00:04<00:06, 33.86it/s]
 42%|####1     | 156/375 [00:04<00:06, 34.10it/s]
 43%|####2     | 160/375 [00:04<00:06, 33.84it/s]
 44%|####3     | 164/375 [00:04<00:06, 34.27it/s]
 45%|####4     | 168/375 [00:04<00:06, 34.33it/s]
 46%|####5     | 172/375 [00:05<00:05, 34.20it/s]
 47%|####6     | 176/375 [00:05<00:05, 34.00it/s]
 48%|####8     | 180/375 [00:05<00:05, 33.51it/s]
 49%|####9     | 184/375 [00:05<00:05, 32.82it/s]
 50%|#####     | 188/375 [00:05<00:05, 32.49it/s]
 51%|#####1    | 192/375 [00:05<00:05, 32.14it/s]
 52%|#####2    | 196/375 [00:05<00:05, 32.17it/s]
 53%|#####3    | 200/375 [00:05<00:05, 32.02it/s]
 54%|#####4    | 204/375 [00:06<00:05, 31.88it/s]
 55%|#####5    | 208/375 [00:06<00:05, 31.80it/s]
 57%|#####6    | 212/375 [00:06<00:05, 31.68it/s]
 58%|#####7    | 216/375 [00:06<00:05, 31.70it/s]
 59%|#####8    | 220/375 [00:06<00:04, 31.80it/s]
 60%|#####9    | 224/375 [00:06<00:04, 32.00it/s]
 61%|######    | 228/375 [00:06<00:04, 32.30it/s]
 62%|######1   | 232/375 [00:06<00:04, 32.44it/s]
 63%|######2   | 236/375 [00:07<00:04, 32.45it/s]
 64%|######4   | 240/375 [00:07<00:04, 32.37it/s]
 65%|######5   | 244/375 [00:07<00:04, 32.01it/s]
 66%|######6   | 248/375 [00:07<00:03, 32.29it/s]
 67%|######7   | 252/375 [00:07<00:03, 32.66it/s]
 68%|######8   | 256/375 [00:07<00:03, 32.76it/s]
 69%|######9   | 260/375 [00:07<00:03, 32.75it/s]
 70%|#######   | 264/375 [00:07<00:03, 32.99it/s]
 71%|#######1  | 268/375 [00:07<00:03, 33.71it/s]
 73%|#######2  | 272/375 [00:08<00:03, 33.99it/s]
 74%|#######3  | 276/375 [00:08<00:02, 34.30it/s]
 75%|#######4  | 280/375 [00:08<00:02, 34.46it/s]
 76%|#######5  | 284/375 [00:08<00:02, 34.62it/s]
 77%|#######6  | 288/375 [00:08<00:02, 34.89it/s]
 78%|#######7  | 292/375 [00:08<00:02, 34.93it/s]
 79%|#######8  | 296/375 [00:08<00:02, 35.04it/s]
 80%|########  | 300/375 [00:08<00:02, 35.04it/s]
 81%|########1 | 304/375 [00:09<00:02, 35.07it/s]
 82%|########2 | 308/375 [00:09<00:01, 34.92it/s]
 83%|########3 | 312/375 [00:09<00:01, 34.98it/s]
 84%|########4 | 316/375 [00:09<00:01, 35.09it/s]
 85%|########5 | 320/375 [00:09<00:01, 35.32it/s]
 86%|########6 | 324/375 [00:09<00:01, 35.47it/s]
 87%|########7 | 328/375 [00:09<00:01, 35.39it/s]
 89%|########8 | 332/375 [00:09<00:01, 35.27it/s]
 90%|########9 | 336/375 [00:09<00:01, 35.11it/s]
 91%|######### | 340/375 [00:10<00:00, 35.13it/s]
 92%|#########1| 344/375 [00:10<00:00, 34.87it/s]
 93%|#########2| 348/375 [00:10<00:00, 35.25it/s]
 94%|#########3| 352/375 [00:10<00:00, 35.28it/s]
 95%|#########4| 356/375 [00:10<00:00, 34.39it/s]
 96%|#########6| 360/375 [00:10<00:00, 32.45it/s]
 97%|#########7| 364/375 [00:10<00:00, 32.33it/s]
 98%|#########8| 368/375 [00:10<00:00, 31.35it/s]
 99%|#########9| 372/375 [00:11<00:00, 31.65it/s]
100%|##########| 375/375 [00:11<00:00, 33.72it/s]

  9 # Generic
 10 import numpy as np
 11 import pandas as pd
 12 import matplotlib.pyplot as plt
 13
 14 # Sklearn
 15 from sklearn.model_selection import train_test_split
 16 from sklearn.datasets import load_iris
 17 from sklearn.datasets import load_breast_cancer
 18 from sklearn.naive_bayes import GaussianNB
 19 from sklearn.linear_model import LogisticRegression
 20 from sklearn.tree import DecisionTreeClassifier
 21 from sklearn.ensemble import RandomForestClassifier
 22 from sklearn.svm import SVC
 23 from sklearn.ensemble import ExtraTreesClassifier
 24 from sklearn.neural_network import MLPClassifier
 25 from sklearn.calibration import CalibratedClassifierCV
 26
 27 # Xgboost
 28 from xgboost import XGBClassifier
 29
 30 # ----------------------------------------
 31 # Load data
 32 # ----------------------------------------
 33 # Seed
 34 seed = 0
 35
 36 # Load dataset
 37 bunch = load_iris()
 38 bunch = load_breast_cancer()
 39 features = list(bunch['feature_names'])
 40
 41 # Create DataFrame
 42 data = pd.DataFrame(data=np.c_[bunch['data'], bunch['target']],
 43                     columns=features + ['target'])
 44
 45 # Create X, y
 46 X = data[bunch['feature_names']]
 47 y = data['target']
 48
 49 # Filter
 50 X = X.iloc[:500, :3]
 51 y = y.iloc[:500]
 52
 53
 54 # Split dataset
 55 X_train, X_test, y_train, y_test = \
 56     train_test_split(X, y, random_state=seed)
 57
 58
 59 # ----------------------------------------
 60 # Classifiers
 61 # ----------------------------------------
 62 # Train classifier
 63 gnb = GaussianNB()
 64 llr = LogisticRegression()
 65 dtc = DecisionTreeClassifier(random_state=seed)
 66 rfc = RandomForestClassifier(random_state=seed)
 67 xgb = XGBClassifier(
 68     min_child_weight=0.005,
 69     eta= 0.05, gamma= 0.2,
 70     max_depth= 4,
 71     n_estimators= 100)
 72 ann = MLPClassifier()
 73 svm = SVC(probability=True)
 74 etc = ExtraTreesClassifier()
 75
 76 # List
 77 clfs = [gnb, llr, dtc, rfc, xgb, ann, svm, etc]
 78 #clfs = [svm, dtc]
 79
 80 # Fit
 81 for clf in clfs:
 82     clf.fit(X_train, y_train)
 83
 84 # ----------------------------------------
 85 # Find shap values
 86 # ----------------------------------------
 87 # Possible explainers:
 88 #    - shap.DeepExplainer
 89 #    - shap.KernelExplainer
 90 #    - shap.TreeExplainer
 91 #    - shap.LinearExplainer
 92 #    - shap.Exact
 93 #    - shap.Explainer
 94
 95 # Import
 96 import shap
 97
 98 # Initialise
 99 shap.initjs()
100
101
102 def predict_proba(x):
103     return clf.predict_proba(x)[:, 1]
104
105 # Loop
106 for clf in clfs:
107
108     try:
109         # Show classifier
110         print("\n" + '-'*80)
111         print("Classifier: %s" % clf)
112
113         """
114         # Create shap explainer
115         if isinstance(clf,
116             (DecisionTreeClassifier,
117              ExtraTreesClassifier,
118              XGBClassifier)):
119             # Set Tree explainer
120             explainer = shap.TreeExplainer(clf)
121         elif isinstance(clf, LogisticRegression):
122             # Masker
123             masker = shap.maskers.Independent(X_train, max_samples=100)
124             # Set Linear explainer
125             #explainer = shap.LinearExplainer(predict_proba)#, masker)
126             explainer = shap.Explainer(predict_proba, masker)
127         elif isinstance(clf, int):
128             # Set NN explainer
129             explainer = shap.DeepExplainer(clf)
130         else:
131             # Works for [svc]
132             # If too many examples (pass aux to explainer).
133             aux = shap.sample(X_train, 100)
134             # Set generic kernel explainer
135             explainer = shap.KernelExplainer(predict_proba, aux)
136         """
137
138         # Sample to speed up processing.
139         sample = shap.sample(X_train, 100)
140
141         if isinstance(clf, XGBClassifier):
142             # Works for [llr, dtc, etc, xgb]
143             explainer = shap.Explainer(clf, sample)
144         else:
145             # Works for all but [xgb]
146             explainer = shap.KernelExplainer(predict_proba, sample)
147
148         # Show kernel type
149         print("Kernel type: %s" % type(explainer))
150
151         # Get shap values
152         #shap_values = explainer(X)
153         shap_values = explainer.shap_values(X_train)
154
155         print(shap_values)
156
157
158         # Show information
159         print("base value: %s" % \
160               explainer.expected_value)
161         #print("shap_values: %s" % \
162         #      str(shap_values.shape))
163
164         # Summary plot
165         plt.figure()
166         plot_summary = shap.summary_plot( \
167             explainer.shap_values(X_train),
168             X_train, cmap='viridis',
169             show=False)
170
171         # Format
172         plt.title(clf.__class__.__name__)
173         plt.tight_layout()
174
175     except Exception as e:
176         print("Error: %s" % e)
177
178 # Show
179 plt.show()

Total running time of the script: ( 1 minutes 28.721 seconds)

Gallery generated by Sphinx-Gallery