From: W. Trevor King Date: Tue, 19 Mar 2013 13:04:30 +0000 (-0400) Subject: pca.py: Add ability to drop columns (questions) from input data X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e492cafd589c4123518ad0b9a596dab18a1d78e0;p=blog.git pca.py: Add ability to drop columns (questions) from input data --- diff --git a/posts/Factor_analysis/pca.py b/posts/Factor_analysis/pca.py index 03d1639..0e8aaaf 100755 --- a/posts/Factor_analysis/pca.py +++ b/posts/Factor_analysis/pca.py @@ -597,6 +597,9 @@ if __name__ == '__main__': parser.add_argument( '-u', dest='unitary', default=False, action='store_const', const=True, help='use unitary eigenvalues for factor loading') + parser.add_argument( + '-d', dest='drop', type=int, action='append', + help='drop a column from the analysis') parser.add_argument( 'path', help='path to the tab-delimited data file to analyze') @@ -604,4 +607,6 @@ if __name__ == '__main__': args = parser.parse_args() scores = _numpy.genfromtxt(fname=args.path, delimiter='\t') + if args.drop: + scores = _numpy.delete(scores, args.drop, axis=1) analyze(scores=scores, output_dim=args.output_dim, unitary=args.unitary)