Ejemplo n.º 1
0
import numpy as np
import pandas as pd
import sys

from utils import load_removed_features, load_features_and_preprocess
from spp_ut_settings import Settings

# afeat_select = ['stat', 'spectral', 'sp_entropy', 'mfj']
afeat_select = ['stat', 'spectral', 'sp_entropy']
# afeat_select = ['stat', 'sp_entropy']

settings = Settings()
print settings
settings.remove_covariate_shift = False
settings.qthr = -1


def match_electrode(i, s):
    ind = s.index('-')
    return int(s[0:ind]) == i


def get_nr_feat_electrode(feat_names2):

    vals = np.zeros((16, 1))
    for iiel in range(0, 16):
        nr = sum(map(lambda s: match_electrode(iiel + 1, s), feat_names2))
        vals[iiel, 0] = nr

    return vals
Ejemplo n.º 2
0
# feat_select = [['sp_entropy'],
#                ['spectral'],
#                ['sp_entropy']]

# feat_select = [['stat'], ['stat'], ['stat']]
# feat_select = [['spectral'], ['spectral'], ['spectral']]
feat_select = [['sp_entropy'], ['sp_entropy'], ['sp_entropy']]
# feat_select = [['mfj'], ['mfj'], ['mfj']]

# sall = ['stat', 'spectral', 'sp_entropy', 'mfj', 'corr']
# feat_select = [sall, sall, sall]

d_data_train = dict()
d_data_test = dict()

settings = Settings()
print settings

for i in range(0, 3):

    nsubject = i + 1

    K = [settings.kfoldCV]
    R = settings.repeatCVouter

    # XTRAIN, ytrain, aFeatNames, aFiles_tr, plabels, data_q = load_features('train', nsubject, feat_select)
    # XTEST, ytest, aFeatNames_ts, dummy4, dummy5, dummy3 = load_features('test', nsubject, feat_select)

    d_tr, d_ts = load_features_and_preprocess(nsubject, feat_select[i], settings=settings)
    XTRAIN, ytrain, aFeatNames_tr, aFiles_tr, plabels_tr, data_q_tr, ind_nan_tr = d_tr[0], d_tr[1], d_tr[2], d_tr[3], \
                                                                                  d_tr[4], d_tr[5], d_tr[6]
# tscv = TimeSeriesSplitGroupSafe(n_splits=3)
# print X.shape
# print(tscv)
#
# for train_index, test_index in tscv.split(X):
#     print("TRAIN:", train_index, "TEST:", test_index)
#     # print X[train_index]
#     # print X[test_index]
#     # X_train, X_test = X[train_index], X[test_index]
#     # y_train, y_test = y[train_index], y[test_index]

from utils import load_features_and_preprocess
from spp_ut_settings import Settings
# from sklearn.utils import shuffle

settings = Settings()
settings.remove_outliers = False
settings.standardize = False
settings.drop_nan = False

d_tr, d_ts = load_features_and_preprocess(3, ['stat'], settings, verbose=True)
XTRAIN, ytrain, aFeatNames_tr, aFiles_tr, plabels_tr, data_q_tr, ind_nan_tr = d_tr[0], d_tr[1], d_tr[2], d_tr[3], \
                                                                              d_tr[4], d_tr[5], d_tr[6]

ytrain = ytrain.ravel()
XTRAIN, ytrain, plabels_tr = insert_pathol_to_normal_random_keep_order(XTRAIN, ytrain, plabels_tr)

tscv = TimeSeriesSplitGroupSafe(n_splits=100)

p = np.unique(plabels_tr)