From 3a7121ad1800dbb569acbe8af37974a2d6114b0f Mon Sep 17 00:00:00 2001 From: Vasil Zlatanov Date: Wed, 14 Nov 2018 22:20:11 +0000 Subject: Change ensemble to bagging --- train.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/train.py b/train.py index ef2df18..faa6f65 100755 --- a/train.py +++ b/train.py @@ -191,7 +191,7 @@ def main(): parser.add_argument("-i", "--data", help="Input CSV file", required=True) parser.add_argument("-m", "--eigen", help="Number of eigenvalues in model", type=int, default = 10 ) parser.add_argument("-M", "--reigen", help="Number of eigenvalues in model", type=int) - parser.add_argument("-e", "--ensemble", help="Number of bagging ensembles to use", type=int) + parser.add_argument("-b", "--bagging", help="Number of bagging baggings to use", type=int) parser.add_argument("-n", "--neighbors", help="How many neighbors to use", type=int, default = 1) ##USING STANDARD 1 FOR NN ACCURACY parser.add_argument("-f", "--faces", help="Show faces", type=int, default = 0) @@ -218,14 +218,14 @@ def main(): faces_train, faces_test, target_train, target_test = test_split(n_faces, raw_faces, args.split, args.seed) - if args.ensemble: + if args.bagging: n_training_faces = int(round(n_cases*(1 - args.split))) - faces_train_bagged = np.zeros((args.ensemble, n_faces, n_training_faces, n_pixels)) - for x in range(args.ensemble): + faces_train_bagged = np.zeros((args.bagging, n_faces, n_training_faces, n_pixels)) + for x in range(args.bagging): for k in range(n_faces): samples = random.choices(range(n_training_faces), k=n_training_faces) faces_train_bagged[x][k] = [faces_train[i+n_training_faces*k] for i in samples] - faces_train_bagged = faces_train_bagged.reshape(args.ensemble, n_faces*n_training_faces, n_pixels) + faces_train_bagged = faces_train_bagged.reshape(args.bagging, n_faces*n_training_faces, n_pixels) if args.classifyalt: faces_train = faces_train.reshape(n_faces, int(faces_train.shape[0]/n_faces), n_pixels) @@ -254,10 +254,10 @@ def main(): plt.ylabel('Recognition Accuracy (%)') plt.grid(True) plt.show() - elif args.ensemble: - rec_error = np.zeros((args.ensemble, n_faces, faces_test.shape[0])) - target_pred = np.zeros((args.ensemble, target_test.shape[0])) - for i in range(args.ensemble): + elif args.bagging: + rec_error = np.zeros((args.bagging, n_faces, faces_test.shape[0])) + target_pred = np.zeros((args.bagging, target_test.shape[0])) + for i in range(args.bagging): target_pred[i], rec_error[i] = test_model(args.eigen, faces_train_bagged[i], faces_test, target_train, target_test, args) target_pred_comb = np.zeros(target_pred.shape[1]) -- cgit v1.2.3-54-g00ecf