大家好,谢谢你们能帮我解决这个问题。我有关于参与临床试验的病人的多种数据,我的目标是预测他们的死亡/非死亡。这些数据由两个数据集组成,第一组是静态的(年龄、性别、ecc),第二组是动态的(在多次测试中收集的分析结果,如%红细胞压积、%钠、血压等)。我知道,如果我只有静态数据,我会使用任何ML分类算法,当然,在只有动态数据的情况下,“正确”的方法是构建一个LSTM,但两者都让我有点困惑。在这种情况下,我可以建立什么样的模型?我在考虑两个模型,其中第一个(静态)的输出变成了第二个(动态)的输入。是个好主意吗?谢谢。
发布于 2020-06-01 11:48:30
您所指的是所谓的多输入模型,可以很好地构建在大多数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。该模型将两者兼而有之,将递归层应用于前者,并将它们连在一起,通过密集层进行联合。
当然,其中许多参数将取决于您的数据,但至少这个示例将给您一个如何构建这样的模型的想法。
还有一个有趣的项目条件全神经网络也是为了这个目的而设计的。值得一看。
https://datascience.stackexchange.com/questions/75217
复制相似问题