From ec8550ebb7b76e237a0a4eddf9e7bad5459f521d Mon Sep 17 00:00:00 2001 From: Vasil Zlatanov Date: Tue, 20 Nov 2018 19:46:57 +0000 Subject: Remove old code comments and redundant lines --- train.py | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'train.py') diff --git a/train.py b/train.py index b4b8194..3a15fa0 100755 --- a/train.py +++ b/train.py @@ -90,14 +90,10 @@ def test_model(M, faces_train, faces_test, target_train, target_test, args): if args.pca or args.pca_r: # faces_pca containcts the principial components or the M most variant eigenvectors average_face = np.mean(faces_train, axis=0) - #PLOTTING MEAN FACE - #plt.imshow(average_face.reshape([46,56]).T, cmap = 'gist_gray') - plt.show() if args.classifyalt: deviations_tr = np.ones(n_pixels) else: deviations_tr = np.std(faces_train, axis=0) - # deviations_tst = np.std(faces_test, axis=0) faces_train = normalise_faces(deviations_tr, average_face, faces_train) faces_test = normalise_faces(deviations_tr, average_face, faces_test) if (args.pca_r): @@ -106,11 +102,6 @@ def test_model(M, faces_train, faces_test, target_train, target_test, args): e_vecs = e_vecs/LA.norm(e_vecs, axis = 0) else: e_vals, e_vecs = LA.eigh(np.cov(faces_train.T)) - # e_vecs = normalise_faces(np.mean(e_vecs,axis=0), e_vecs) - #PLOTTING NON-ZERO EVALS - #if args.pca: - # plt.semilogy(range(2576), np.absolute(416*np.flip(e_vals))) - # plt.show() e_vals = np.flip(e_vals) e_vecs = np.fliplr(e_vecs).T @@ -125,7 +116,6 @@ def test_model(M, faces_train, faces_test, target_train, target_test, args): e_vecs = e_vecs[:M] deviations_tr = np.flip(deviations_tr) - # deviations_tst = np.flip(deviations_tst) faces_train = np.dot(faces_train, e_vecs.T) faces_test = np.dot(faces_test, e_vecs.T) @@ -151,7 +141,6 @@ def test_model(M, faces_train, faces_test, target_train, target_test, args): faces_test = lda.transform(faces_test) class_means = lda.means_ e_vals = lda.explained_variance_ratio_ - # scatter_matrix = lda.covariance_; print("Rank of scatter:", LA.matrix_rank(scatter_matrix)) if args.faces: if args.lda: @@ -171,7 +160,6 @@ def test_model(M, faces_train, faces_test, target_train, target_test, args): plt.show() if args.grapheigen: - #graph_eigen() # Colors for distinct individuals cols = ['#{:06x}'.format(randint(0, 0xffffff)) for i in range(n_faces)] pltCol = [cols[int(k)] for k in target_train] @@ -192,11 +180,9 @@ def test_model(M, faces_train, faces_test, target_train, target_test, args): avg_targer_prob = np.zeros(n_faces) for i in range (n_faces): avg_targer_prob[i] = (targer_prob_vec[2*i] + targer_prob_vec[2*i + 1])/2 - #WE CAN FIX THIS BY RESHAPING TARGER_PROB_VEC AND TAKING THE MEAN ON THE RIGHT AXIS plt.bar(range(n_faces), avg_targer_prob) plt.show() - #Better n_neighbors = 2 return target_pred, distances def main(): @@ -208,13 +194,10 @@ def main(): parser.add_argument("-b", "--bagging", help="Number of bags to use", action='store_true') parser.add_argument("-R", "--random", help="Number of eigen value to randomise", 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) parser.add_argument("-c", "--principal", help="Show principal components", action='store_true') parser.add_argument("-s", "--seed", help="Seed to use", type=int, default=0) parser.add_argument("-t", "--split", help="Fractoin of data to use for testing", type=float, default=0.3) - ### best split for lda = 22 - ### best plit for pca = 20 parser.add_argument("-2", "--grapheigen", help="Swow 2D graph of targets versus principal components", action='store_true') parser.add_argument("-p", "--pca", help="Use PCA", action='store_true') @@ -305,4 +288,3 @@ def main(): draw_results(args, target_test, target_pred) if __name__ == "__main__": - main() -- cgit v1.2.3-54-g00ecf