临床试验中的静态和动态数据

数据挖掘 机器学习 分类 时间序列 lstm
2022-02-20 16:07:00

大家好,提前感谢那些会帮助我解决这个问题的人。我有多项关于参与临床试验的患者的数据,我的目标是预测他们的死亡/非死亡。这些数据由两个数据集组成,第一个是静态的(年龄、性别 ecc),第二个是动态的(在多个会话中收集的分析结果,如 %hematocrit、%sodium、血压等)。我知道,如果我只有静态数据,我会使用任何 ML 分类算法,当然,如果只有动态数据,“正确”的方法是构建 LSTM,但对于它们,我有点困惑。在这种情况下,我可以构建哪种模型?我在考虑两个模型,其中第一个(静态)的输出成为第二个(动态)的输入。这是个好主意吗?谢谢你。

1个回答

您所指的称为多输入模型,可以在大多数 deel 学习框架中轻松构建。这个想法是将两种类型的数据作为单独的输入,然后根据它们的类型使用特定的层(循环层对数据进行排序,CNN 对图像,等等),然后将它们连接在一起。

如果您可以使用 Keras,那么功能 Api非常适合手头的任务。您的问题的代码示例(基于文档中给出的示例)可能是:

from keras.layers import Input, Embedding, LSTM, Dense, merge
from keras.models import Model

# headline input: meant to receive sequences of 100 integers, between 1 and 10000.
# note that we can name any layer by passing it a "name" argument.
main_input = Input(shape=(100,), dtype='int32', name='main_input')

# this embedding layer will encode the input sequence
# into a sequence of dense 512-dimensional vectors.
x = Embedding(output_dim=512, input_dim=10000, input_length=100)(main_input)

# a LSTM will transform the vector sequence into a single vector,
# containing information about the entire sequence
lstm_out = LSTM(32)(x)

#At this point, we feed into the model our auxiliary input data by concatenating it with the LSTM output:

auxiliary_input = Input(shape=(5,), name='aux_input')
x = merge([lstm_out, auxiliary_input], mode='concat')

# we stack a deep fully-connected network on top
x = Dense(64, activation='relu')(x)
x = Dense(64, activation='relu')(x)
x = Dense(64, activation='relu')(x)

# and finally we add the main logistic regression layer
main_output = Dense(1, activation='sigmoid', name='main_output')(x)

#This defines a model with two inputss:
model = Model(input=[main_input, auxiliary_input], output=main_output)

#Then compite and train
model.compile(optimizer='rmsprop', loss='binary_crossentropy')
model.fit([headline_data, additional_data], labels,
          nb_epoch=50, batch_size=32)

在您的情况下,动态数据将是 ,headline_input而您的静态数据是auxiliary_input. 该模型将两者都采用,将循环层应用于前者并将它们连接起来以通过密集层传递联合。

当然,其中许多参数将取决于您的数据,但至少这个示例将让您了解如何构建此类模型。

还有一个有趣的项目conditionall RNN也是为此目的。值得一看。