Ejemplo n.º 1
0
def make_bagset(in_path, out_path, k=7):
    seq_dict = files.get_seqs(in_path)
    files.make_dir(out_path)
    for i in range(k):
        dataset_i = resample(seq_dict)
        out_i = "%s/bag%d" % (out_path, i)
        files.save_seqs(dataset_i, out_i)
    files.save_seqs(seq_dict, "%s/full" % out_path)
Ejemplo n.º 2
0
def simple_exp(in_path, out_path=None, n_epochs=1000):
    seq_dict = files.get_seqs(in_path)
    train, test = files.split(seq_dict)
    X, y, names, params = prepare_data(train)
    model = deep.make_conv(params)
    model.fit(X, y, epochs=n_epochs)
    if (out_path):
        extrac_feats(model, seq_dict, out_path)
    else:
        test_model(model, test)
Ejemplo n.º 3
0
def norm_seqs(in_path, out_path):
    seqs = files.get_seqs(in_path)
    fun = sigma_norm(seqs)
    new_seqs = {}
    for name_i, seq_i in seqs.items():
        seq_i = [fun(ts_j, j) for j, ts_j in enumerate(seq_i.T)]
        seq_i = np.array(seq_i).T
        new_seqs[name_i] = seq_i
    files.make_dir(out_path)
    for name_i, seq_i in new_seqs.items():
        out_i = "%s/%s" % (out_path, name_i)
        np.save(out_i, seq_i)
Ejemplo n.º 4
0
def agum_template(in_path, out_path, agum):
    seq_dict = files.get_seqs(in_path)
    train, test = files.split(seq_dict)
    agum_train = []
    for name_i, seq_i in train.items():
        agum_train.append((name_i, seq_i))
        new_seqs = [agum_k(seq_i) for agum_k in agum]
        new_seqs = list(itertools.chain(*new_seqs))
        for j, seq_j in enumerate(new_seqs):
            name_j = "%s_%d" % (name_i, j)
            agum_train.append((name_j, seq_j))
    agum_data = agum_train + list(test.items())
    agum_data = dict(agum_data)
    files.save_seqs(agum_data, out_path)
    print(len(agum_data))
Ejemplo n.º 5
0
def show_ts(in_path, out_path):
    seqs = files.get_seqs(in_path)
    dim = list(seqs.values())[0].shape[-1]
    cats = get_cats(seqs.keys())[0]
    files.make_dir(out_path)
    for cat_i, names_i in cats.items():
        in_i = "%s/%d" % (out_path, cat_i)
        files.make_dir(in_i)
        for name_ij in names_i:
            out_ij = "%s/%s" % (in_i, name_ij)
            seq_ij = seqs[name_ij]
            for ts_k in seq_ij.T:
                plt.plot(ts_k)
            plt.savefig(out_ij)
            plt.clf()
            plt.close()
Ejemplo n.º 6
0
def jackknife(in_path, out_path):
    seq_dict = files.get_seqs(in_path)
    dim = list(seq_dict.values())[0].shape[1]
    X = np.array(list(seq_dict.values()))
    names = list(seq_dict.keys())
    files.make_dir(out_path)
    for i in range(dim):
        sub_i = np.delete(X, [i], axis=2)
        out_i = "%s/bag%d" % (out_path, i)
        sub_dict_i = {name_j: sub_i[j] for j, name_j in enumerate(names)}
        files.save_seqs(sub_dict_i, out_i)
    files.save_seqs(seq_dict, "%s/full" % out_path)


#make_bagset("../MSR/agum","../MSR/bagging",k=7)
#train_bag("../MSR/subspace","../MSR/sub_feats")
#jackknife("../MSR/agum","../MSR/subspace")
Ejemplo n.º 7
0
def ae_exp(in_path, out_path):
    files.make_dir(out_path)
    seq_dict = files.get_seqs(in_path)
    pairs = dtw.make_pairwise_distance(seq_dict)
    save(pairs, "%s/%s" % (out_path, "pairs"))
Ejemplo n.º 8
0
def compute_stats(in_path,out_path):
    seqs=files.get_seqs(in_path)
    feat_dict=feats.Feats()
    for name_i,seq_i in seqs.items():
        feat_dict[name_i]=EBTF(seq_i)
    feat_dict.save(out_path)
Ejemplo n.º 9
0
def upsample(in_path, out_path, size=128):
    seq_dict = files.get_seqs(in_path)
    print(len(seq_dict))
    spline = SplineUpsampling(size)
    seq_dict = {name_i: spline(seq_i) for name_i, seq_i in seq_dict.items()}
    files.save_seqs(seq_dict, out_path)