コード例 #1
0
                'broca',
                'gestures',
                'hearing',
                'learning',
                'motor',
                'movement',
                'speech',
                'syntactic',
                'verbal',
                'visuospatial']
    folds = [features[a:b] for a, b in [(0,6), (6,12), (12,18)]]
    data = []
    with open('times.txt', 'w+') as log:
        for fold_id, fold in enumerate(folds):
            for ds in range(6,11):
                with Timer('DOWNSAMPLED BY {ds}\n'.format_map(locals()),
                           print_func=log.write) as t:
                    matrix = BrainMatrix('emd', downsample=ds, name='validation')
                    matrix.compute_distances(fold)
                    inconsistency = matrix.plot_dendrogram()
                    stress = matrix.plot_mds(metric=False)
                    data.append([ds, fold_id, t.elapsed, inconsistency, stress])

    df = pd.DataFrame(columns=['downsample', 'fold', 'time', 'inconsistency', 'stress'], data=data)
    df.to_pickle('validation.pkl')

    #f, ax = sns.plt.subplots(figsize=(7, 7))
    #ax.set(yscale="log")
    #sns.pointplot(x='features', y='time', hue='downsample', data=df)
    #sns.plt.show()
コード例 #2
0
ファイル: test.py プロジェクト: fredcallaway/brain_matrix
from brain_matrix import BrainMatrix, load_brainmatrix
from utils import Timer

if __name__ == '__main__':
    print('\n\nRUNNING TESTS\n----------------------------')
    with Timer('RUN TIME'):
        # euclidaen_emd 
        matrix = BrainMatrix('emd', downsample=30, name='test')
        matrix.compute_distances(['syntactic', 'speech', 'semantic', 'music'])
        del matrix
        matrix = load_brainmatrix('test')
        assert isinstance(matrix['semantic']['speech'].distance, float)
        # create some figure in figs/
        matrix.plot_mds(clusters=2, dim=3, interactive=True)
        matrix.plot_dendrogram()
        matrix.write_csv()
        print('TESTS PASSED')