SHARE
TWEET

Untitled

a guest Jun 27th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top