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 |
X_train = data.drop(['Chance of Admit', 'Accept'], axis=1)
y_reg = data['Chance of Admit']
y_cls = data['Accept']
from sklearn.preprocessing import MinMaxScaler from sklearn.linear_model import LinearRegression, LogisticRegression
scaler = MinMaxScaler() X_train_scaled = scaler.fit_transform(X_train)
lin_reg = LinearRegression() lin_reg.fit(X_train_scaled, y_reg)
log_reg = LogisticRegression() log_reg.fit(X_train_scaled, y_cls)
print(lin_reg.coef_)
[0.03052087 0.01665433 0.00668971
0.00326926 0.01724815 0.0661691 ]
print(log_reg.coef_)
[[1.28985577 0.49441086 0.47593379
0.05434322 0.41800927 1.31980189]]
import matplotlib.pyplot as plt
plt.bar(X_train.columns, lin_reg.coef_)
import matplotlib.pyplot as plt
plt.bar(X_train.columns, log_reg.coef_[0])
Explainable AI in Python