SHARE
TWEET

Untitled

a guest May 19th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. max_allowed_depth = []
  2. test_accuracy = []
  3. train_accuracy = []
  4.  
  5. for max_depth in range(1, 32):
  6.     dt_classifier = tree.DecisionTreeClassifier(max_depth=max_depth, random_state=my_seed)
  7.     dt_classifier.fit(X_train, Y_train)
  8.     Yhat = dt_classifier.predict(X_test)
  9.     accuracy_train = dt_classifier.score(X_train, Y_train)
  10.     accuracy_test = dt_classifier.score(X_test, Y_test)
  11.     max_allowed_depth.append( max_depth )
  12.     test_accuracy.append( accuracy_test )
  13.     train_accuracy.append( accuracy_train )
  14.     print(max_depth, accuracy_test)
  15.  
  16. plt.title('Accuracy vs Max_allowed_depth')
  17. plt.plot(max_allowed_depth, test_accuracy, label='test_accuracy')
  18. plt.plot(max_allowed_depth, train_accuracy, label='train_accuracy')
  19. plt.xlabel = 'max_allowed_depth'
  20. plt.ylbabel = 'test_accuracy'
  21. plt.show()
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