Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sklearn.ensemble import GradientBoostingClassifier
- import pandas as pd
- data = pd.read_csv("../data/data.csv", header=0)
- X = data.iloc[:,1:-1]
- y = data.iloc[:,0]
- gbdt = GradientBoostingClassifier(criterion='friedman_mse', init=None,
- learning_rate=0.1, loss='deviance', max_depth=3,
- max_features=None, max_leaf_nodes=None,
- min_impurity_split=1e-07, min_samples_leaf=1,
- min_samples_split=2, min_weight_fraction_leaf=0.0,
- n_estimators=90, presort='auto', random_state=None,
- subsample=1.0, verbose=0, warm_start=False)
- gbdt.fit(X, y)
- import pydotplus
- from sklearn import tree
- for i in range(gbdt.estimators_.shape[0]):
- dot_data = tree.export_graphviz(gbdt.estimators_[i][0], out_file=None)
- graph = pydotplus.graph_from_dot_data(dot_data)
- graph.write_pdf("../data/trees/tree_"+str(i)+".pdf")
Add Comment
Please, Sign In to add comment