This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lime_exp.as_list() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shap.summary_plot(shap_values, X) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import shap | |
shap.initjs() | |
shap_explainer = shap.TreeExplainer(model) | |
shap_values = shap_explainer.shap_values(X) | |
shap.force_plot(shap_explainer.expected_value, shap_values[1, :], test_1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lime_exp.as_list() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lime_exp.predict_proba |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lime | |
from lime import lime_tabular | |
lime_explainer = lime_tabular.LimeTabularExplainer( | |
training_data=np.array(X_train), | |
feature_names=X_train.columns, | |
class_names=['bad', 'good'], | |
mode='classification' | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from xgboost import XGBClassifier | |
model = XGBClassifier() | |
model.fit(X_train, y_train) | |
test_1 = X_test.iloc[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.model_selection import train_test_split | |
X = wine.drop('quality', axis=1) | |
y = wine['quality'] | |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
wine = pd.read_csv('wine.csv') | |
wine.head() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_color(magnitude): | |
if magnitude <= 5: | |
c_outline, c_fill = '#ffda79', '#ffda79' | |
m_opacity, f_opacity = 0.2, 0.1 | |
else: | |
c_outline, c_fill = '#c0392b', '#e74c3c' | |
m_opacity, f_opacity = 1, 1 | |
return c_outline, c_fill, m_opacity, f_opacity | |
def generate_popup(magnitude, depth): |
NewerOlder