def __init__(self, n_components=4, reg=None, log=None, transform_into='csp_space', norm_trace=False, name="CSP"): super(CSP, self).__init__(name) self.n_components = n_components self.reg = reg self.log = log self.transform_into = transform_into self.norm_trace = norm_trace self.model = mne_CSP(n_components, reg, log, 'epoch', transform_into, norm_trace)
s_id[s], npp_params, clean=False, physical=True, downsample=False) data_size = y_train.shape[0] shuffle_index = utils.shuffle_data(data_size) x_train = x_train[shuffle_index] x_train = np.squeeze(x_train) y_train = y_train[shuffle_index] print(x_train.shape) csp = mne_CSP(n_components=6, transform_into='average_power', log=False, cov_est='epoch') # build model lr = LogisticRegression(solver='sag', max_iter=200, C=0.01) model = Pipeline([('csp_power', csp), ('LR', lr)]) model.fit(x_train, y_train) # Test Model y_pred = np.argmax(model.predict_proba(np.squeeze(x_test)), axis=1) bca = utils.bca(y_test, y_pred) acc = np.sum(y_pred == y_test).astype(np.float32) / len(y_pred) print('{}: acc-{} bca-{}'.format(data_name, acc, bca)) acc_mean += acc bca_mean += bca