cv = ShuffleSplit(n_splits=100, test_size=0.33, random_state=0) ADB = AdaBoostClassifier( DecisionTreeClassifier(max_depth=2), n_estimator=grid_search.best_params['n_estimators'], learning_rate=grid_search.best_params_['learning_rate'], random_state=0) plot_learning_curve(ADB, title1, X, y, ylim=(0.4, 1.01), cv=cv, n_jobs=4) # In[7]: #Draw the validation curve title2 = "Validation Curve with Adaboost " xlabel = "n_estimators" ylabel = "Score" ADB = AdaBoostClassifier( DecisionTreeClassifier(max_depth=2), learning_rate=grid_search.best_params_['learning_rate'], random_state=0) plot_validation_curve(ADB, title2, xlabel, ylabel, X, y, param_name='n_estimators', ylim=None, cv=cv, n_jobs=4, param_range=np.arange(1, 200, 20)) plt.show()
grid_search.param_grid['n_neighbors'][::-1]) plt.xlabel('weights') plt.ylabel('n_neighbors') # In[6]: #Draw learning curve X, y = arr_in, arr_out title1 = "Learning Curve (K Nearest Neighbors)" cv = StratifiedKFold(arr_out, n_folds=3) estimator = KNeighborsClassifier() plot_learning_curve(estimator, title1, X, y, ylim=None, cv=cv, n_jobs=4) # In[7]: #Draw validation curve title2 = "Validation Curve with K Nearest Neighbors " xlabel = "n_neighbors" ylabel = "Score" plot_validation_curve(estimator, title2, xlabel, ylabel, X, y, param_name='n_neighbors', ylim=None, cv=cv, n_jobs=1, param_range=np.arange(1, 10, 1)) plt.show()
plt.xlabel('min_samples_split') plt.ylabel('max_depth') # In[6]: # Draw the learning curve X, y = arr_in, arr_out title1 = "Learning Curves (Decision Tree Classifier)" cv = ShuffleSplit(n_splits=100, test_size=0.33, random_state=0) estimator = DecisionTreeClassifier() plot_learning_curve(estimator, title1, X, y, ylim=(0.4, 1.01), cv=cv, n_jobs=4) # In[7] # Draw the validation curve title2 = "Validation Curve with Decision Tree Classifier " xlabel = "max_depth" ylabel = "Score" plot_validation_curve(estimator, title2, xlabel, ylabel, X, y, param_name='max_depth', ylim=None, cv=cv, n_jobs=1, param_range=np.arange(1, max_d)) plt.show()