Guest User

Untitled

a guest
Dec 11th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. from sklearn.ensemble import GradientBoostingClassifier
  2. import pandas as pd
  3.  
  4. data = pd.read_csv("../data/data.csv", header=0)
  5.  
  6. X = data.iloc[:,1:-1]
  7. y = data.iloc[:,0]
  8.  
  9. gbdt = GradientBoostingClassifier(criterion='friedman_mse', init=None,
  10. learning_rate=0.1, loss='deviance', max_depth=3,
  11. max_features=None, max_leaf_nodes=None,
  12. min_impurity_split=1e-07, min_samples_leaf=1,
  13. min_samples_split=2, min_weight_fraction_leaf=0.0,
  14. n_estimators=90, presort='auto', random_state=None,
  15. subsample=1.0, verbose=0, warm_start=False)
  16.  
  17. gbdt.fit(X, y)
  18.  
  19. import pydotplus
  20. from sklearn import tree
  21.  
  22. for i in range(gbdt.estimators_.shape[0]):
  23. dot_data = tree.export_graphviz(gbdt.estimators_[i][0], out_file=None)
  24. graph = pydotplus.graph_from_dot_data(dot_data)
  25. graph.write_pdf("../data/trees/tree_"+str(i)+".pdf")
Add Comment
Please, Sign In to add comment