Skip to content

Instantly share code, notes, and snippets.

@monspo1
Last active March 30, 2016 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monspo1/23e9b201ca361a436dcb610360a9578e to your computer and use it in GitHub Desktop.
Save monspo1/23e9b201ca361a436dcb610360a9578e to your computer and use it in GitHub Desktop.
# (1) Fit a decision tree model on the training set with the default setting.
from sklearn import tree
import sklearn.grid_search as gs
tree_model = tree.DecisionTreeClassifier()
tree_model.fit(x_train, y_train)
grid_para_tree = {'criterion': ['gini', 'entropy'], 'max_depth': range(1, 11)}
grid_search_tree = gs.GridSearchCV(tree_model, grid_para_tree, cv=5, scoring='logloss')
grid_search_tree.fit(x_train, y_train)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment