y_pred_rfc_moe = rfc_moe.predict(X_test) print 'MOE RFC Metrics: ' print 'Best n_estimators: ', n_estimators print 'Best max_features: ', max_features print 'Best max_depth: ', max_depth print 'Best min_samples_leaf: ' min_samples_leaf rfc_moe_acc, rfc_moe_prec, rfc_moe_rec, rfc_moe_cm, rfc_moe_cm_full = get_scores(y_test,y_pred_rfc_moe) # Get MOE best ABC Model & it's metrics abc_moe_param, abc_moe_accuracy = do_abc_MOE(num_points_to_sample, X_train, y_train) print 'Best ABC train param: ', abc_moe_param print 'Best ABC train Accuracy: ', abc_moe_accuracy n_estimators = abc_moe_param[0] learning_rate = abc_moe_param[1] abc = AdaBoostClassifier((DecisionTreeClassifier(max_depth=2)),n_estimators=n_estimators, learning_rate=learning_rate) abc_moe.fit(X_train, y_train) y_pred_abc_moe = abc_moe.predict(X_test) print 'MOE ABC Metrics: ' print 'Best n_estimators: ', n_estimators print 'Best learning_rate: ', learning_rate abc_moe_acc, abc_moe_prec, abc_moe_rec, abc_moe_cm, abc_moe_cm_full = get_scores(y_test,y_pred_abc_moe) # Boosting SVC, RFC & ABC y_all = np.clumn_stack((y_pred_svc_linear_moe, y_pred_svc_rbf_moe, y_pred_rfc_moe, y_pred_abc_moe)) y_pred_all = (stats.mode(y_all)[0][0]).astype(int) print 'MOE All Metrics: ' all_moe_acc, all_moe_prec, all_moe_rec, all_moe_cm, all_moe_cm_full = get_scores(y_test,y_pred_all)
svc_parameters = {'kernel':('linear', 'rbf'), 'C':C_range, 'gamma': gamma_range} y_pred_svc = do_svc(X_train, y_train, X_test, svc_parameters) print 'GridSearch SVC Metrics:' svc_acc, svc_prec, svc_rec, svc_cm, svc_cm_full = get_scores(y_test,y_pred_svc) ''' # Get GridSearch best RFC Model & it's metrics n_estimators_range = [100, 500, 1000] max_features_range = [9, 24, 561] # log2(nfeatures=562) = 24, sqrt(561) = 9 max_depth_range = [None, 6, 8] min_samples_leaf_range = [1, 4, 6] rfc_parameters = {'criterion':('gini', 'entropy'), 'n_estimators': n_estimators_range, 'max_features': max_features_range, 'max_depth': max_depth_range, 'min_samples_leaf': min_samples_leaf_range} y_pred_rfc = do_rfc(X_train, y_train, X_test, rfc_parameters) print 'GridSearch RFC Metrics: ' rfc_acc, rfc_prec, rfc_rec, rfc_cm, rfc_cm_full = get_scores(y_test,y_pred_rfc) # Get GridSearch best ABC Model & it's metrics n_estimators_range = [5, 10, 25, 50, 100, 500, 1000] learning_rate_range = [0.1, 0.3, 0.5, 0.7, 0.9, 1] abc_parameters = {'n_estimators': n_estimators_range, 'learning_rate': learning_rate_range} y_pred_abc = do_abc(X_train, y_train, X_test, abc_parameters) print 'GridSearch ABC Metrics: ' abc_acc, abc_prec, abc_rec, abc_cm, abc_cm_full = get_scores(y_test,y_pred_abc) # Boosting SVC, RFC & ABC y_all = np.clumn_stack((y_pred_svc, y_pred_rfc, y_pred_abc)) y_pred_all = (stats.mode(y_all)[0][0]).astype(int) print 'All Metrics: ' all_acc, all_prec, all_rec, all_cm, all_cm_full = get_scores(y_test,y_pred_all)