def __work(): print "Reading", filename count, dicts = mushroom_dicts(filename) seed = shuffle.generate_seed(count) o = mushroom(filename, count, dicts, seed) pickle.dump(o, open(filename + ".bin", "w")) print "Written", filename + ".bin"
def optdigits(filename): fh = open(filename, "r") data = [] labels = [] fl = fh.readlines() for line in fl: vals = line.split('\n')[0].rsplit(',') if len(vals) != 65: break data.append([int(vals[i]) for i in range(64)]) labels.append(vals[64]) shuffle.shuffle(data, labels, shuffle.generate_seed(len(data))) return numpy.array(data), labels
def glass(filename): fh = open(filename, "r") data = [] labels = [] fl = fh.readlines() for line in fl: vals = line.split('\n')[0].rsplit(',') if len(vals) != 11: break data.append([float(vals[i + 1]) for i in range(9)]) labels.append(tr(vals[10])) shuffle.shuffle(data, labels, shuffle.generate_seed(len(data))) return numpy.array(data), labels