if torch.cuda.is_available():
    print("Let's go CUDA!!!!!")
    cuda = torch.device('cuda')
else:
    print("No CUDA,,,")
    cuda = torch.device('cpu')

np.random.seed(777)
kfold = 5
# y_value = args.y



data, xdata, ydata = DATA_PREPROCESS_SH(log=False)
xdata = NORMALIZATION(xdata, 'standard')
ydata = CATEGORIZATION_v2(ydata)
for i in range(len(ydata[0])):
    print(Counter(ydata[:, i]))


def _ychoice(y):
    this = np.transpose(np.concatenate((np.transpose(xdata), [ydata[:, y]]), axis=0))
    this = np.array(this)
    # this = this.astype(float)
    np.random.shuffle(this)
    return this
# data.to_csv('kky1.csv', index=None)


Ejemplo n.º 2
0
# ppl who has last lipid profile values
data2 = data.loc[data.RAND.isin(list(lab_count[lab_count>=2].index))]
# 이전 값
shifted = data2.groupby('RAND').shift(1)

# merge shifted and data
data2 = data2.join(shifted.rename(columns=lambda x: x+'_shifted')).dropna(axis=0).loc[:,['RAND_KEY','L3008_cholesterol_shifted','L3061_tg_shifted','L3062_hdl_shifted','L3068_ldl_shifted']]

# merge shifted var. and data
df_sort_2 = pd.merge(df_sort, data2, on='RAND_KEY').drop('RAND_KEY', axis=1).dropna(axis=0)
data = df_sort_2
xdata = df_sort_2[df_sort_2.columns.difference(['L3008_cholesterol', 'L3061_tg', 'L3062_hdl', 'L3068_ldl'])]
ydata = df_sort_2[['L3008_cholesterol', 'L3061_tg', 'L3062_hdl', 'L3068_ldl']]

size = data.shape
data = np.concatenate((NORMALIZATION(xdata, 'standard'), ydata), axis=1)
# data.to_csv('kky1.csv', index=None)

# 0~6 features, 7~10 labels
data = np.array(data)
data = data.astype(float)

# Train / Test split
np.random.shuffle(data)
thres = int(0.8 * len(data))
train = data[:thres]
test = data[thres:]



def _TData(train, y):
Ejemplo n.º 3
0
    return trainloader


def Parameters(net):
    criterion = nn.CrossEntropyLoss()
    optimizer = optim.SGD(net.parameters(), lr=0.001, momentum=0.9)

    return criterion, optimizer


training, num_vars, num_classes = DataLoad(clinical_filepath, gene_data, mode)

# 여기는 GCN 포함
if gcn_mode:
    from net_emerging import gf
    gf = NORMALIZATION(gf, 'standard')
    training = np.transpose(np.vstack((np.transpose(gf), [training[:, -1]])))

batch_size = 32
kfold = 5

np.random.seed(777)
torch.manual_seed(777)

np.random.shuffle(training)
_split_1 = KFOLD(training, kfold)
test = _split_1[0]

_train_tmp = []
for i in range(1, 5):
    _train_tmp.append(_split_1[i])