Changeset 604 for mds-and-trees/mds_plot.py
- Timestamp:
- 08/30/16 17:08:10 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mds-and-trees/mds_plot.py
r603 r604 63 63 return Y, evals 64 64 65 def rand_jitter(arr ):66 stdev = arr.max() / 100.67 return arr + np.random.randn(len(arr)) * stdev * 265 def rand_jitter(arr, jitter): 66 stdev = (arr.max()-arr.min()) / 100. * jitter #dispersion proportional to range 67 return arr + np.random.randn(len(arr)) * stdev 68 68 69 69 … … 91 91 percent_variances = [sum(variances[:i+1])/sum(variances) for i in range(len(variances))] 92 92 for i,pv in enumerate(percent_variances): 93 print( i+1,"dimension:",pv)93 print("In",i+1,"dimensions:",pv) 94 94 95 95 dim = min(dim, len(embed[0])) … … 107 107 ax = fig.add_subplot(111, projection='3d') 108 108 109 add_jitter = lambda tab : rand_jitter(tab ) if jitter==1else tab109 add_jitter = lambda tab : rand_jitter(tab, jitter) if jitter>0 else tab 110 110 111 111 x_dim = len(coordinates[0]) … … 120 120 # print(point) 121 121 for label, x, y in zip(labels, points[0], points[1]): 122 #if label not in knownlabels:123 # knownlabels.append(label)124 # colors.append('#ff0000')125 122 for key in labelconvert: 126 123 if label.startswith(key): … … 165 162 parser.add_argument('--dim', required=False, help='number of dimensions of the new space') 166 163 parser.add_argument('--sep', required=False, help='separator of the source file') 167 parser.add_argument('--j', required=False, help='for j =1 random jitter is added tothe plot')164 parser.add_argument('--j', required=False, help='for j>0, random jitter is added to points in the plot') 168 165 169 166 args = parser.parse_args() 170 167 set_value = lambda value, default : default if value == None else value 171 main(args.input, int(set_value(args.dim, 3)), set_value(args.output, ""), int(set_value(args.j, 0)), set_value(args.sep, "\t"))168 main(args.input, int(set_value(args.dim, 3)), set_value(args.output, ""), float(set_value(args.j, 0)), set_value(args.sep, "\t"))
Note: See TracChangeset
for help on using the changeset viewer.