Explainable AI in Python
Fouad Trad
Machine Learning Engineer





| GRE Score | TOEFL Score | University Rating | SOP | LOR | CGPA | Chance of Admit | Accept |
|---|---|---|---|---|---|---|---|
| 337 | 118 | 4 | 4.5 | 4.5 | 9.65 | 0.92 | 1 |
| 324 | 107 | 4 | 4 | 4.5 | 8.87 | 0.76 | 1 |
| 316 | 104 | 3 | 3 | 3.5 | 8 | 0.72 | 1 |
| 322 | 110 | 3 | 3.5 | 2.5 | 8.67 | 0.8 | 1 |
| 314 | 103 | 2 | 2 | 3 | 8.21 | 0.45 | 0 |
regressor: predicts chance of admitclassifier: predicts acceptanceXfrom lime.lime_tabular import LimeTabularExplainerinstance = X.iloc[1,:]explainer_reg = LimeTabularExplainer( X.values,feature_names=X.columns,mode='regression')explanation_reg = explainer_reg.explain_instance(instance.values,regressor.predict)
from lime.lime_tabular import LimeTabularExplainerinstance = X.iloc[1,:]explainer_class = LimeTabularExplainer( X.values,feature_names=X.columns,mode='classification')explanation_class = explainer_class.explain_instance(instance.values,classifier.predict_proba)
explanation_reg.as_pyplot_figure()

explanation_class.as_pyplot_figure()

shap.waterfall_plot(...)

explanation_class.as_pyplot_figure()

Explainable AI in Python