import xgboost
import shap
import plotly.express as px
import dalex as dx
X, y = shap.datasets.boston()
model = xgboost.XGBRegressor().fit(X, y)
explainer = shap.Explainer(model)
boston_rf_exp = dx.Explainer(model, X, y,
label="Boston houses RF Pipeline")
shap_values = explainer(X)
shap.plots.force(shap_values[0])
shap.plots.force(shap_values[0])
shap.plots.force(shap_values)
shap.plots.beeswarm(shap_values)
shap.plots.scatter(shap_values[:,"RM"], color=shap_values)
bd = boston_rf_exp.predict_parts(house, type='break_down')bd.plot()
from sklearn.inspection import permutation_importancer = permutation_importance(model, X, y)
px.bar(x=X.columns, y=model.feature_importances_)
cp = boston_rf_exp.predict_profile(house)cp.plot(variables=['NOX', 'RM', 'DIS', 'LSTAT'])
from sklearn.linear_model import LinearRegressionfrom sklearn.preprocessing import scalelinarModel = LinearRegression().fit(scale(X), y)px.bar(y=linarModel.coef_, x=X.columns)
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.