aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasil Zlatanov <vasil@netcraft.com>2018-11-14 22:20:11 +0000
committerVasil Zlatanov <vasil@netcraft.com>2018-11-14 22:20:11 +0000
commit3a7121ad1800dbb569acbe8af37974a2d6114b0f (patch)
tree3b48ca11f1894b904f5219e36d68fd1043135e68
parenta94130756408dcb0884e5edca00408e2faf2c65b (diff)
downloadvz215_np1915-3a7121ad1800dbb569acbe8af37974a2d6114b0f.tar.gz
vz215_np1915-3a7121ad1800dbb569acbe8af37974a2d6114b0f.tar.bz2
vz215_np1915-3a7121ad1800dbb569acbe8af37974a2d6114b0f.zip
Change ensemble to bagging
-rwxr-xr-xtrain.py18
1 files 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])