Skip to content

Instantly share code, notes, and snippets.

@michelkana
Created August 31, 2021 13:19
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 michelkana/bd46a041d776e1872f89de58eef31858 to your computer and use it in GitHub Desktop.
Save michelkana/bd46a041d776e1872f89de58eef31858 to your computer and use it in GitHub Desktop.
best_nb_iterations = np.array([ab_test_scores[:,i].argmax() for i in range(len(tree_depths)) ])
best_test_scores = np.array([ab_test_scores[best_nb_iterations[i],i] for i in range(len(tree_depths)) ])
optimal_tree_depth_idx = best_test_scores.argmax()
optimal_nb_iterations = best_nb_iterations[optimal_tree_depth_idx]
optimal_tree_depth = tree_depths[optimal_tree_depth_idx]
optimal_test_score = ab_test_scores[optimal_nb_iterations, optimal_tree_depth_idx]
optimal_train_score = ab_train_scores[optimal_nb_iterations, optimal_tree_depth_idx]
print('The combination of base learner depth {} and {} iterations achieves the best accuracy {}% on test set \
and {}% on training set.'.format(optimal_tree_depth, optimal_nb_iterations, round(optimal_test_score*100,5),
round(optimal_train_score*100,5)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment