import sklearn


def make_train_pair(filename):
    h5 = open_h5_file_read(filename)
    title = get_title(h5)
    pitches = get_segments_pitches(h5)[:11] # limit: only look at beginning
    pitch_diffs = [pitches[i] - pitches[i - 1] for i in xrange(1, len(pitches))]
    h5.close()
    return {'title': title, 'pitch_diffs': pitch_diffs}
# some lines omitted
neigh = NearestNeighbors(n_neighbors=1) # predict the closest song
# a title list is also maintained
neigh.fit([sum(diff) for diff in pitch_diff_list[5000:]])
neigh.kneighbors(sum(pitch_diff_list[2029])) # example prediction
@@ -8,16 +8,52 @@
 sklearn%0A
+from hdf5_getters import *%0Aimport os
 %0A%0Adef ma
@@ -368,16 +368,270 @@
 _diffs%7D%0A
+%0Afor root, dirs, files in os.walk('data'):%0A    files = glob.glob(os.path.join(root, '*h5'))%0A    for f in files:%0A        train_pair = make_train_pair(f)%0A        titles.append(train_pair%5B'title'%5D)%0A        pitch_diff_list.append(train_pair%5B'pitch_diffs'%5D)%0A%0A
 # some l

Add corresponding hdf5 parsing file