Skip to content

Commit

Permalink
fix sample size, nearest neighbors runs
Browse files Browse the repository at this point in the history
  • Loading branch information
aflock committed Feb 17, 2012
1 parent 5d63a0a commit 99b4500
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sem2/get_samples.py
Expand Up @@ -145,7 +145,7 @@ def main(options, args):
for p_num, pixel in enumerate(row):
in_bounds = p_num > p/2 and row_num > p/2 and row_num < s-(p/2) and p_num < s-(p/2)
if pixel > 200 and in_bounds:
slice_coords = ((row_num-p/2, row_num+p/2+2), (p_num-p/2, p_num+p/2+2))
slice_coords = ((row_num-p/2, row_num+p/2+1), (p_num-p/2, p_num+p/2+1))
#print "CR found %s", pixel
"""
fig = plt.figure(1, (1., 3.))
Expand Down Expand Up @@ -194,7 +194,7 @@ def main(options, args):
for s in top_1000:
row_num, p_num = s[0]
#saving the sample as data
sl_co = ((row_num-p/2, row_num+p/2+2), (p_num-p/2, p_num+p/2+2))
sl_co = ((row_num-p/2, row_num+p/2+1), (p_num-p/2, p_num+p/2+1))
print sl_co
slice = original_file_data[sl_co[0][0]:sl_co[0][1], sl_co[1][0]:sl_co[1][1]]
formatted_slice = {'x': slice.flatten(), 'y':0}
Expand Down
6 changes: 6 additions & 0 deletions sem2/nearest_neighbors.py
Expand Up @@ -16,6 +16,12 @@
neg_samples = pickle.load(open("%s/samples/negative.p" % data_dir,"rb"))
pos_samples = pickle.load(open("%s/samples/positive.p" % data_dir,"rb"))
samples = neg_samples + pos_samples
#sanitize for incorrectly shaped samples
for s in samples:
if s['x'].size is not 81:
print s['x'].size
print "removing sample : \n", s
samples.remove(s)
shuffle(samples)
num_s = len(samples)
training_set = samples[:num_s/2]
Expand Down

0 comments on commit 99b4500

Please sign in to comment.