Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from catboost import CatBoostClassifier
- model = CatBoostClassifier(iterations=300)
- model.fit(X, y,cat_features=cat_features)
- pool1 = Pool(data=X, label=y, cat_features=cat_features)
- shap_values = model.get_feature_importance(data=pool1, fstr_type='ShapValues', verbose=10000)
- shap_values.shape
- Output: (32769, 10)
- X.shape
- Output: (32769, 9)
- shap.initjs()
- shap.force_plot(shap_values[0,:-1], X.iloc[0,:])
- shap.initjs()
- shap.summary_plot(shap_values[:,:-1], X)
- explainer = shap.TreeExplainer(model,data=pool1)
- #Also tried:
- explainer = shap.TreeExplainer(model,data=X)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement