Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. from catboost import CatBoostClassifier
  2. model = CatBoostClassifier(iterations=300)
  3. model.fit(X, y,cat_features=cat_features)
  4.  
  5. pool1 = Pool(data=X, label=y, cat_features=cat_features)
  6. shap_values = model.get_feature_importance(data=pool1, fstr_type='ShapValues', verbose=10000)
  7.  
  8. shap_values.shape
  9. Output: (32769, 10)
  10. X.shape
  11. Output: (32769, 9)
  12.  
  13. shap.initjs()
  14. shap.force_plot(shap_values[0,:-1], X.iloc[0,:])
  15.  
  16. shap.initjs()
  17. shap.summary_plot(shap_values[:,:-1], X)
  18.  
  19. explainer = shap.TreeExplainer(model,data=pool1)
  20. #Also tried:
  21. explainer = shap.TreeExplainer(model,data=X)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement